遇到的错误如下:
$ sudo pip install jupyter
Collecting jupyter
Using cached https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting nbconvert (from jupyter)
Using cached https://files.pythonhosted.org/packages/79/6c/05a569e9f703d18aacb89b7ad6075b404e8a4afde2c26b73ca77bb644b14/nbconvert-5.6.1-py2.py3-none-any.whl
Collecting notebook (from jupyter)
Using cached https://files.pythonhosted.org/packages/1b/c5/5772fb4654cce834a097a2fa49baace3a7b375470ddf52c599e372c765b3/notebook-5.7.16-py2.py3-none-any.whl
Collecting jupyter-console (from jupyter)
Using cached https://files.pythonhosted.org/packages/77/82/6469cd7fccf7958cbe5dce2e623f1e3c5e27f1bb1ad36d90519bc2d5d370/jupyter_console-5.2.0-py2.py3-none-any.whl
Requirement already satisfied: ipykernel in /usr/local/lib/python2.7/dist-packages (from jupyter)
Collecting ipywidgets (from jupyter)
Using cached https://files.pythonhosted.org/packages/14/3f/fa7fcf85061819f5a10ed09eaef38fe97d0f3f91d14674bbb26c3fc2a622/ipywidgets-7.8.1-py2.py3-none-any.whl
Collecting qtconsole (from jupyter)
Using cached https://files.pythonhosted.org/packages/fb/ef/6cf8a7301726a7b7149e95102c70f809542dfcd916826e8dccc0d90b2605/qtconsole-5.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-5OIjqO/qtconsole/setup.py", line 18
print(error, file=sys.stderr)
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5OIjqO/qtconsole/
这个错误的直接原因是setup.py脚本语法有问题,应该是python版本不匹配导致的。解决方法是强制安装低版本的qtconsole,安装命令为“sudo pip install qtconsole==4.7.7”。如遇其他错误,通常也是版本不匹配导致的,尝试安装一个更低的版本即可解决。最后安装成功如下:
$ sudo pip install jupyter
Collecting jupyter
Using cached https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Requirement already satisfied: nbconvert in /usr/local/lib/python2.7/dist-packages (from jupyter)
Requirement already satisfied: notebook in /usr/local/lib/python2.7/dist-packages (from jupyter)
Collecting jupyter-console (from jupyter)
Using cached https://files.pythonhosted.org/packages/77/82/6469cd7fccf7958cbe5dce2e623f1e3c5e27f1bb1ad36d90519bc2d5d370/jupyter_console-5.2.0-py2.py3-none-any.whl
Requirement already satisfied: ipykernel in /usr/local/lib/python2.7/dist-packages (from jupyter)
Requirement already satisfied: ipywidgets in /usr/local/lib/python2.7/dist-packages (from jupyter)
Requirement already satisfied: qtconsole in /usr/local/lib/python2.7/dist-packages (from jupyter)
Requirement already satisfied: pygments in /usr/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: testpath in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: nbformat>=4.4 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: bleach in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: entrypoints>=0.2.2 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: pandocfilters>=1.4.1 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: defusedxml in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: mistune<2,>=0.8.1 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: jinja2>=2.4 in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: jupyter-core in /usr/local/lib/python2.7/dist-packages (from nbconvert->jupyter)
Requirement already satisfied: terminado>=0.8.1 in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: ipython-genutils in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: tornado<7,>=4.1 in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: prometheus-client in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: Send2Trash in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: jupyter-client<7.0.0,>=5.2.0 in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: pyzmq>=17 in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: ipaddress; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from notebook->jupyter)
Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.0 in /usr/local/lib/python2.7/dist-packages (from jupyter-console->jupyter)
Requirement already satisfied: ipython in /usr/local/lib/python2.7/dist-packages (from jupyter-console->jupyter)
Requirement already satisfied: widgetsnbextension~=3.0.0 in /usr/local/lib/python2.7/dist-packages (from ipywidgets->jupyter)
Requirement already satisfied: qtpy in /usr/local/lib/python2.7/dist-packages (from qtconsole->jupyter)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /usr/local/lib/python2.7/dist-packages (from nbformat>=4.4->nbconvert->jupyter)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2->nbconvert->jupyter)
Requirement already satisfied: enum34; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2->nbconvert->jupyter)
Requirement already satisfied: decorator in /usr/local/lib/python2.7/dist-packages (from traitlets>=4.2->nbconvert->jupyter)
Requirement already satisfied: webencodings in /usr/local/lib/python2.7/dist-packages (from bleach->nbconvert->jupyter)
Requirement already satisfied: packaging in /usr/local/lib/python2.7/dist-packages (from bleach->nbconvert->jupyter)
Requirement already satisfied: configparser>=3.5; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from entrypoints>=0.2.2->nbconvert->jupyter)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/dist-packages (from jinja2>=2.4->nbconvert->jupyter)
Requirement already satisfied: ptyprocess; os_name != "nt" in /usr/local/lib/python2.7/dist-packages (from terminado>=0.8.1->notebook->jupyter)
Requirement already satisfied: singledispatch in /usr/local/lib/python2.7/dist-packages (from tornado<7,>=4.1->notebook->jupyter)
Requirement already satisfied: futures in /usr/local/lib/python2.7/dist-packages (from tornado<7,>=4.1->notebook->jupyter)
Requirement already satisfied: backports-abc>=0.4 in /usr/local/lib/python2.7/dist-packages (from tornado<7,>=4.1->notebook->jupyter)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python2.7/dist-packages (from jupyter-client<7.0.0,>=5.2.0->notebook->jupyter)
Requirement already satisfied: wcwidth in /usr/local/lib/python2.7/dist-packages (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Requirement already satisfied: backports.shutil-get-terminal-size; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/local/lib/python2.7/dist-packages (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pathlib2; python_version == "2.7" or python_version == "3.3" in /usr/local/lib/python2.7/dist-packages (from ipython->jupyter-console->jupyter)
Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python2.7/dist-packages/setuptools-36.6.0-py2.7.egg (from ipython->jupyter-console->jupyter)
Requirement already satisfied: simplegeneric>0.8 in /usr/local/lib/python2.7/dist-packages (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pickleshare in /usr/local/lib/python2.7/dist-packages (from ipython->jupyter-console->jupyter)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python2.7/dist-packages (from packaging->bleach->nbconvert->jupyter)
Requirement already satisfied: backports.functools-lru-cache>=1.2.1; python_version < "3.2" in /usr/local/lib/python2.7/dist-packages (from wcwidth->prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Requirement already satisfied: typing; python_version < "3.5" in /usr/local/lib/python2.7/dist-packages (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython->jupyter-console->jupyter)
Requirement already satisfied: scandir; python_version < "3.5" in /usr/local/lib/python2.7/dist-packages (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython->jupyter-console->jupyter)
Installing collected packages: jupyter-console, jupyter
Successfully installed jupyter-1.0.0 jupyter-console-5.2.0