简体   繁体   中英

Jupyter using the wrong version of python

Hi I've installed python 2.7 but did not remove 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

> 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 --version
Python 2.7.6

as well as my which python seems to give the right out put :

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

I have pip installed for both versions of python. I am not sure how to fix this :(

It could be a problem in your python kernel.json configuration. For example my python kernel is located at:

/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.

It looks like you installed jupyter as an extension of /usr/lib/python2.6 . If so, you'd have to uninstall jupyter and reinstall into your desired python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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