安装django

时间:2019-09-22
本文章向大家介绍安装django,主要包括安装django使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.安装django之前需要安装python及pip,   python与django的对应版本请自行百度

2.安装之后,需要配置python及pip的环境变量,具体配置方法请自行百度

3.django的安装:使用pip install django 默认安装最新版本的django

安装时候若有如下报错:

File "c:\install\python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 402, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

原因:

这是因为pip的默认源在国外,pip install some_packages特别慢,经常会超时,导致安装失败;
所以把pip 更换为国内的镜像,就可以很快的下载安装了。

解决:

临时使用国内镜像

打开cmd命令行输入:

pip install some_package --index https://pypi.mirrors.ustc.edu.cn/simple/
#使用清华大学的镜像

比如安装django库:
pip install django --index https://pypi.tuna.tsinghua.edu.cn/simple
使用国内镜像即可快速下载。

永久使用国内镜像

windows中,在Users目录下直接创建一个pip.ini文件,把下面内容保存即可。
例如我的目录:C:\Users\83979\pip.ini

[global] 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

常用的镜像

阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

原文地址:https://www.cnblogs.com/whyan/p/11565403.html