安装环境
mac环境:MacBook Pro (Retina, 13-inch, Mid 2014),参见文章Jupyter Notebooks 入门,按此文安装
操作如下:
xxx-laptop:~ xxx$python3 -m pip install --upgrade pip
xxx-laptop:~ xxx$ python3 -m pip install jupyter
结果如下:
Collecting jupyter
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x1023cdc50>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)': /simple/jupyter/
...
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x1023cd0f0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)': /simple/jupyter/
Could not find a version that satisfies the requirement jupyter (from versions: )
No matching distribution found for jupyter
多次重试无效。
网上搜索错误“Could not find a version that satisfies the requirement jupyter”,有很多文章,没有按文章重试。
改用如下命令:
xxx-laptop:~ xxx$ pip3 install jupyter
结果:
Collecting jupyter
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x10a3f87f0>: Failed to establish a new connection: [Errno 65] No route to host',)': /packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
....
Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
....
0x10a417e80>: Failed to establish a new connection: [Errno 65] No route to host',))
You are using pip version 9.0.3, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
这里的提示很重要,成功在此
xxx-laptop:~ xxx$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 91kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-20.1.1
升级PIP后,再次pip install jupyter
xxx-laptop:~ xxx$ pip install jupyter
Collecting jupyter
Downloading jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Collecting jupyter-console
Downloading jupyter_console-6.1.0-py2.py3-none-any.whl (21 kB)
Collecting qtconsole
Downloading qtconsole-4.7.4-py2.py3-none-any.whl (118 kB)
|████████████████████████████████| 118 kB 10 kB/s
Collecting nbconvert
Downloading nbconvert-5.6.1-py2.py3-none-any.whl (455 kB)
|████████████████████████████████| 455 kB 95 kB/s
...
完成后,执行jupyter:
jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
[--paths] [--json]
[subcommand]
...
成功。
如果不能自动打开浏览器:
xxx-laptop:~ xxx$ jupyter notebook --generate-config
xxx-laptop:~ xxx$ cd .jupyter/
修改jupyter_notebook_config.py
c.NotebookApp.browser = u'chrome'
c.NotebookApp.notebook_dir = '/Users/xxx/workspace/jupyter'
c.NotebookApp.open_browser = True
保存,重启就可以了。