pip默认使用国外源,下载速度贼慢,甚至报错:
C:\Users\MARS>python -m pip install --user pygal==1.7
Collecting pygal==1.7
Downloading pygal-1.7.0.tar.gz (737 kB)
|████ | 92 kB 2.2 kB/s eta 0:04:47ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
yield
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 449, in read
n = self.readinto(b)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 493, in readinto
n = self.fp.readinto(b)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 631, 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\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
status = self.run(options, args)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
return func(self, options, args)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\commands\install.py", line 325, in run
reqs, check_supported_wheels=not options.target_dir
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\operations\prepare.py", line 469, in prepare_linked_requirement
hashes=self._get_linked_req_hashes(req)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\operations\prepare.py", line 259, in unpack_url
hashes=hashes,
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\operations\prepare.py", line 130, in get_http_url
link, downloader, temp_dir.path, hashes
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\operations\prepare.py", line 282, in _download_http_url
for chunk in download.chunks:
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\cli\progress_bars.py", line 168, in iter
for x in it:
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_internal\network\utils.py", line 88, in response_chunks
decode_content=False,
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\MARS\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, 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 install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
输入命令后,再进行install,秒完成。
C:\Users\MARS>python -m pip install --user pygal==1.7
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pygal==1.7
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/2a/4c07302157297054cf21e2166c05f2ab77d95da3101988856cb0eae62919/pygal-1.7.0.tar.gz (737 kB)
|████████████████████████████████| 737 kB 1.7 MB/s
Building wheels for collected packages: pygal
Building wheel for pygal (setup.py) ... done
Created wheel for pygal: filename=pygal-1.7.0-py3-none-any.whl size=789251 sha256=cec7d590138507d1e6192871b6129484ec6dc502fe16f85b4aa66dfc45f20193
Stored in directory: c:\users\mars\appdata\local\pip\cache\wheels\93\d3\29\86efeeccad77fa0960f2116ecaf0ea4830f728008895f56a1d
Successfully built pygal
Installing collected packages: pygal
Successfully installed pygal-1.7.0