关于python:django安装错误

Django installation error

我安装了python 3.5.2。我也安装了PIP9.0.1。当我输入命令pythonpip --version时,版本号显示出来。但是,当我尝试使用命令pip install Django安装django时,经过一定的百分比后,它停止下载,命令提示出现以下错误。我试着设置路径,但是错误还是出现了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Exception:
Traceback (most recent call last):
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor
equests\packages\urllib3
esponse.py"
, line 232, in_error_catcher
yield
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor
equests\packages\urllib3
esponse.py"
, line 314, in read
data = self._fp.read(amt)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 60, in read
data = self.__fp.read(amt)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\http\client.py", line 448, in read
n = self.readinto(b)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\http\client.py", line 488, in readinto
n = self.fp.readinto(b)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\socket.py",line 575, in readinto
return self._sock.recv_into(b)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\ssl.py", line 575, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip
eq
eq_set.py"
, line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip
eq
eq_set.py"
, line 620, in _prepare_file
session=self.session, hashes=hashes)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 659, in unpack_http_url
hashes)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 571, in written_chunks
for chunk in chunks:
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\utils\ui.py", line 139, in iter
for x in it:
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\download.py", line 560, in resp_read
decode_content=False):
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor
equests\packages\urllib3
esponse.py"
, line 357, in stream
data = self.read(amt=amt, decode_content=decode_content)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor
equests\packages\urllib3
esponse.py"
, line 324, in read
flush_decoder = True
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File"c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor
equests\packages\urllib3
esponse.py"
, line 237, in_error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError:HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.


回溯告诉您的是,分配给一个读取操作的最大时间被占用,因此操作被中止。这可能是由于连接速度低造成的,在这种情况下,快速修复可能是增加安装包的超时时间。试试这个:

pip --default-timeout=500 install django

其中,500是以秒为单位的时间量。随意增减。希望它有帮助。


您应该使用virtualenv

创建虚拟环境。然后安装django:pip install django,而不是Django

!SOF:如何离开/退出/停用python virtualenv?链接