4

I installed jupyter via: /usr/local/opt/python/bin/python2.7 -m pip install jupyter

this install ipython version 4.1.2. However, when I run jupyter notebook, I get:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 83, in <module>
    from IPython.paths import get_ipython_dir
ImportError: No module named IPython.paths

yet, when I run from IPython.paths import get_ipython_dir in the ipython shell directly it works fine. Also when I run /usr/local/opt/python/bin/python2.7 and then the same thing, it runs successfully. Additionally, when I check the sys.executable path in python I get /usr/local/opt/python/bin/python2.7

This doesn't make sense to me. How can Ipython and my normal python (both using /usr/local/opt/python/bin/python2.7) both run this successfully, but my jupyter, installed with that specific python, cannot run the command. Any suggestions?

6
  • It appears that for some reason, your jupyter* scripts have the OS X system python in their hash-bang, not your locally installed one. You can either edit the first line in those scripts (check and edit the first line of /usr/local/bin/jupyter-notebook ), or start the scripts explicitly with the correct Python executable. For example: /usr/local/op/python/bin/python2.7 /usr/local/bin/jupyter-notebook. Commented Mar 22, 2016 at 22:46
  • Also check for an explicitly set PYTHONPATH environment variable. Since these take priority over the default sys.path, they may cause problems. Commented Mar 22, 2016 at 22:48
  • hmm still same error with /usr/local/opt/python/bin/python2.7 /usr/local/bin/jupyter notebook Commented Mar 22, 2016 at 23:08
  • I'm partly surprised that your python executable lives in /usr/local/opt/...; I think that's a Homebrew thing? Could you check that the relevant site-packages directory (either in /usr/local/lib/python2.7 or in /usr/local/opt/python/lib/pyhton2.7 contains the notebook directory? Commented Mar 23, 2016 at 1:40
  • Also, in your normal Python shell, what is sys.path? And outside it, what is PYTHONPATH? Commented Mar 23, 2016 at 1:41

2 Answers 2

4

I had the same problem. Just now this helped me. Someone might find this useful.

    from IPython.paths import get_ipython_dir
ImportError: No module named IPython.paths

So I was running Python 3 on Linux mint 17. I first uninstalled jupyter from my system using the command.

sudo -H pip3 uninstall jupyter

After successfully uninstalling I installed jupyter again with the following command.

sudo -H pip3 install jupyter

And when I launched jupyter again using

jupyter notebook

The kernel didn't die or didn't restart. Everything works fine now. I hope atleast one person finds this useful.

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

Comments

0

Upgrade ipython:

pip install ipython==5.3.0

If you cannot uninstall ipython, try this:

sudo -H pip install --ignore-installed -U ipython==5.3.0

Comments

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.