
正文
pip 安装出现异常
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
MacBookPro:~ mac$ pip install numpyCollecting numpy Downloading numpy-1.13.1-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB) 32% |██████████▎ | 1.5MB 10kB/s eta 0:04:49Exception:Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 232, in _error_catcher yield File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read data = self._fp.read(amt) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read data = self.__fp.read(amt) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 448, in read n = self.readinto(b) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 488, in readinto n = self.fp.readinto(b) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py", line 575, in readinto return self._sock.recv_into(b) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 929, in recv_into return self.read(nbytes, buffer) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 791, in read return self._sslobj.read(len, buffer) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 575, in read v = self._sslobj.read(len, buffer)socket.timeout: The read operation timed outDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/commands/install.py", line 324, in run requirement_set.prepare_files(finder) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 821, in unpack_url hashes=hashes File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 659, in unpack_http_url hashes) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 882, in _download_http_url _download_url(resp, link, content_file, hashes) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/utils/ui.py", line 139, in iter for x in it: File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py", line 560, in resp_read decode_content=False): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream data = self.read(amt=amt, decode_content=decode_content) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read flush_decoder = True File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 77, in __exit__ self.gen.throw(type, value, traceback) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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.
解决方法
通过pip安装numpy的时候,可能会报上面的错误,大陆通过FQ手段,是可能解决该问题的。下面给个不用FQ的办法。
使用国内镜像下载python库的办法。
终端输入命令
pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ pandas MacBookPro:~ mac$ pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ pandasCollecting pandas Downloading https://mirrors.ustc.edu.cn/pypi/web/packages/1a/99/253f7096b12481941623205fc81e67aaf86c1e0d17026d286b53da799fd2/pandas-0.20.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (14.7MB) 100% |████████████████████████████████| 14.7MB 48kB/sCollecting pytz>=2011k (from pandas) Downloading https://mirrors.ustc.edu.cn/pypi/web/packages/55/62/e7cd0e15b76062d298413f14bb4ec3cd8568a22d274427f9c3c7286969f4/pytz-2017.2-py2.py3-none-any.whl (484kB) 100% |████████████████████████████████| 491kB 1.1MB/sCollecting python-dateutil>=2 (from pandas) Downloading https://mirrors.ustc.edu.cn/pypi/web/packages/4b/0d/7ed381ab4fe80b8ebf34411d14f253e1cf3e56e2820ffa1d8844b23859a2/python_dateutil-2.6.1-py2.py3-none-any.whl (194kB) 100% |████████████████████████████████| 194kB 988kB/sCollecting numpy>=1.7.0 (from pandas) Downloading https://mirrors.ustc.edu.cn/pypi/web/packages/d9/aa/850b4461a43bbd1d2ff75c97de4cbae7a06884c5c351c5c2a5cfb796a71b/numpy-1.13.1-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB) 100% |████████████████████████████████| 4.5MB 169kB/sRequirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from python-dateutil>=2->pandas)Installing collected packages: pytz, python-dateutil, numpy, pandasSuccessfully installed numpy-1.13.1 pandas-0.20.3 python-dateutil-2.6.1 pytz-2017.2MacBookPro:~ mac$ pip install numpyRequirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packagesMacBookPro:~ mac$ cd /Library/FFilesystems/ Fonts/ Frameworks/MacBookPro:~ mac$ cd /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/sitesite-packages/ site.pyMacBookPro:~ mac$ cd /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/README packaging-16.8.dist-info/ pytz/__pycache__/ pandas/ pytz-2017.2.dist-info/appdirs-1.4.3.dist-info/ pandas-0.20.3.dist-info/ setuptools/appdirs.py pip/ setuptools-35.0.2.dist-info/dateutil/ pip-9.0.1.dist-info/ six-1.10.0.dist-info/easy_install.py pkg_resources/ six.pyMacBookPro:~ mac$ cd /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/MacBookPro:site-packages mac$ lsREADME packaging-16.8.dist-info pytz__pycache__ pandas pytz-2017.2.dist-infoappdirs-1.4.3.dist-info pandas-0.20.3.dist-info setuptoolsappdirs.py pip setuptools-35.0.2.dist-infodateutil pip-9.0.1.dist-info six-1.10.0.dist-infoeasy_install.py pkg_resources six.pynumpy pyparsing-2.2.0.dist-info you_getnumpy-1.13.1.dist-info pyparsing.py you_get-0.4.652.dist-infopackaging python_dateutil-2.6.1.dist-info
注:--index后面也可以换成别的镜像,比如http://mirrors.sohu.com/python/






