将python2内核添加到随python3安装的Jupyter中

时间:2018-11-06 08:58:28

标签: python-2.7 jupyter-notebook

我尝试通过documents安装:

➜  ~ python2 -m pip --version
pip 18.1 from /home/l0o0/.local/lib/python2.7/site-packages/pip (python 2.7)
➜  ~ python2 -m pip install ipykernel
Looking in indexes: https://pypi.douban.com/simple/
Collecting ipykernel
  Downloading https://pypi.doubanio.com/packages/11/0b/95330660f8cc5d63428b9886c800ea8d68842fd866389cf579acca4915be/ipykernel-5.1.0.tar.gz (101kB)
    100% |████████████████████████████████| 102kB 1.3MB/s
  Installing build dependencies ... error
  Complete output from command /usr/bin/python2 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-DtDn1W --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com -- setuptools wheel ipython>=5 jupyter_core>=4.2 jupyter_client:
  Looking in indexes: https://pypi.douban.com/simple/
  Collecting setuptools
    Downloading https://pypi.doubanio.com/packages/82/a1/ba6fb41367b375f5cb653d1317d8ca263c636cff6566e2da1b0da716069d/setuptools-40.5.0-py2.py3-none-any.whl (569kB)
  Collecting wheel
    Downloading https://pypi.doubanio.com/packages/5a/9b/6aebe9e2636d35d1a93772fa644c828303e1d5d124e8a88f156f42ac4b87/wheel-0.32.2-py2.py3-none-any.whl
  Collecting ipython>=5
    Downloading https://pypi.doubanio.com/packages/f3/c3/6c0af5b99d9551fa7b33c674d8f1232033678dcc817098e7a4ac8cd0baf1/ipython-7.1.1.tar.gz (5.1MB)
      Complete output from command python setup.py egg_info:

      IPython 7.0+ supports Python 3.5 and above.
      When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
      Python 3.3 and 3.4 were supported up to IPython 6.x.

      See IPython `README.rst` file for more information:

          https://github.com/ipython/ipython/blob/master/README.rst

      Python sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0) detected.



      ----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-BoFK6H/ipython/

  ----------------------------------------
Command "/usr/bin/python2 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-DtDn1W --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com -- setuptools wheel ipython>=5 jupyter_core>=4.2 jupyter_client" failed with error code 1 in None

默认情况下,似乎安装了错误的版本。根据错误消息,Ipython 5.X适用于python2.X:

python2 -m pip install ipykernel==5.1

打印了相同的错误。 Using both Python 2.x and Python 3.x in IPython Notebook使用virtualenv env安装ipykernel。但我不喜欢使用conda西装。我尝试使用virtualenv创建一个环境。但是我遇到了同样的错误。

另一个线程How do I add python3 kernel to jupyter (IPython)

使用jupyter kernlspec添加新内核:

jupyter kernelspec install /usr/local/Cellar/python3/3.6.1/bin/

但是我不知道Ubuntu 16.04中的哪个python文件夹? /usr/bin/python2不是目录。有人可以成功添加python2内核吗?

也许我应该放弃它,因为python2将于2020年淘汰。

0 个答案:

没有答案