16

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 :(

2 Answers 2

16

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.

Sign up to request clarification or add additional context in comments.

4 Comments

This was helpful. For Windows users, the path to your kernel.json might be something like this: C:\Users[username]\AppData\Roaming\jupyter\kernels\pythonX where x is python 2 or 3.
there is no kernels folder in AppData\Roaming\jupyter
I didn't find any folder at /usr/local/share/jupyter/kernels/python/
For me, it was at /usr/local/share/jupyter/kernels/python3/kernel.json. Note this file can be updated automatically by running ipython3 kernel install (and remember to log out and log in terminal after update).
3

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.

/usr/lib/python2.6 -m pip uninstall jupyter && python -m pip install jupyter

1 Comment

even after uninstalling jupyter and reinstalling in python 3.8, it's still trying to launch nonexistant "C:\program files\python37\python.exe"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.