我安装了python 3.5.2。我也安装了pip 9.0.1。当我输入命令python
或pip --version
时,会显示版本号。但是当我尝试使用命令pip install Django
安装django时,在一定百分比之后,它会停止下载并在命令提示符处出现以下错误。我试图设置路径,但仍然出现错误。
Exception:
Traceback (most recent call last):
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 232, in_error_catcher
yield
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.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\req\req_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\req\req_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\requests\packages\urllib3\response.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\requests\packages\urllib3\response.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\requests\packages\urllib3\response.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.
答案 0 :(得分:1)
回溯告诉您的是,分配给一个读取操作的最大时间已用完,因此操作已中止。这可能是由于连接速度低,在这种情况下,快速修复可能会增加安装包的超时时间。试试这个:
pip --default-timeout=500 install django
其中500
是以秒为单位的时间量。随意增加/减少它。希望它有所帮助。
答案 1 :(得分:0)
您应该使用virtualenv
创建虚拟环境。然后安装django:pip install django
,而不是Django
!SOF:如何离开/退出/停用python virtualenv? Link