简体   繁体   English

Jupyter使用了错误版本的python

[英]Jupyter using the wrong version of python

Hi I've installed python 2.7 but did not remove 2.6. 嗨,我已经安装了python 2.7,但没有删除2.6。 i've added 2.7 to the path and also as an alias but it seems like when I do jupyter notebook it tries to access 2.6 我已经添加了2.7的路径,也作为别名,但似乎当我做jupyter笔记本,它试图访问2.6

> jupyter notebook
Traceback (most recent call last):
File "jupyter-notebook", line 7, in <module>
 from notebook.notebookapp import main
 File "/usr/lib/python2.6/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/usr/lib/python2.6/site-packages/notebook/nbextensions.py", line 226, in  <module>
from traitlets import Bool, Enum, Unicode
File "/usr/lib/python2.6/site-packages/traitlets/__init__.py", line 1, in <module>
from .traitlets import *
File "/usr/lib/python2.6/site-packages/traitlets/traitlets.py", line 1291
return {n: t for (n, t) in cls.class_traits(**metadata).items()
               ^

My python version seems to point to 2.7 我的python版本似乎指向2.7

$ python --version
Python 2.7.6

as well as my which python seems to give the right out put : 以及我的哪个python似乎给出了正确的输出:

$ which python
alias python='/usr/local/bin/python2.7'
/usr/local/bin/python2.7

I have pip installed for both versions of python. 我为这两个版本的python安装了pip。 I am not sure how to fix this :( 我不知道如何解决这个问题:(

It could be a problem in your python kernel.json configuration. 这可能是你的python kernel.json配置中的一个问题。 For example my python kernel is located at: 例如,我的python内核位于:

/usr/local/share/jupyter/kernels/python/kernel.json

and contains: 并包含:

    {
     "language": "python",
     "display_name": "Python 2.7",
     "argv": [
      "/usr/local/bin/python2.7",
      "-m",
      "ipykernel",
      "-f",
      "{connection_file}"
     ]
    }

Make sure that the path in argv section points to correct version of python. 确保argv部分中的路径指向正确的python版本。

It looks like you installed jupyter as an extension of /usr/lib/python2.6 . 看起来你安装了jupyter作为/usr/lib/python2.6的扩展。 If so, you'd have to uninstall jupyter and reinstall into your desired python. 如果是这样,你必须卸载jupyter并重新安装到你想要的python中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM