Rav*_*ina 5 command-line python3 pip 16.04
我正在尝试使用安装jupyter notebook,pip所以我首先安装pip3:
sudo apt-get install --no-install-recommends python3-pip
Run Code Online (Sandbox Code Playgroud)
然后我跑了:
sudo pip3 install jupyter
Run Code Online (Sandbox Code Playgroud)
下载包时,notebook它会等待几秒钟,然后失败并出现很多错误,其末尾如下所示:
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/response.py", line 231, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.
Run Code Online (Sandbox Code Playgroud)
我的 Ubuntu 版本是:16.04 (Xenial),并且我运行在相当慢的互联网连接上。
软件包notebook大小约为6.9 MB,如果您在低速互联网连接上运行,则安装很可能会因超时而失败。
我通过更新解决了这个问题pip3,但是我也会建议另一种方法,如果您无法升级pip3,请使用这个,这也可以完成工作。
您可以使用--default-timeoutswitch 来解决这个问题,例如:
sudo pip --default-timeout=1000 install jupyter
Run Code Online (Sandbox Code Playgroud)
它应该忽略超时并且安装将成功完成。
对我有用的另一件事是更新pip3,Ubuntu 存储库中的更新非常旧:8.1.1编写本指南时的最后一个版本是:9.0.1。我建议这种方法只是因为您不必每次尝试安装新软件包时都运行pip3with --default-timeout,当然您也可以使用别名;)无论什么对您有用。
顺便说一句,我不喜欢以 root 身份安装 python 软件包,所以我建议使用--userswitch 自己在本地安装它,但如果您试图使这个软件包广泛的系统可用,那么请使用sudo.
pip3 install --upgrade pip --user
Run Code Online (Sandbox Code Playgroud)
如果您遇到同样的错误,现在您知道如何修复它,只需使用--default-timeoutswitch 来升级即可pip。
现在它应该可以正常工作,没有任何错误:
pip3 install jupyter --user
Run Code Online (Sandbox Code Playgroud)