21

Trying to open Jupyter Notebook (OSX 10.11.4) I get the following error:

$ jupyter-notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/Users/geotheory/Library/Python/2.7/lib/python/site-packages/notebook/__init__.py", line 25, in <module>
    from .nbextensions import install_nbextension
  File "/Users/geotheory/Library/Python/2.7/lib/python/site-packages/notebook/nbextensions.py", line 23, in <module>
    from jupyter_core.paths import jupyter_data_dir, jupyter_path, SYSTEM_JUPYTER_PATH
ImportError: No module named jupyter_core.paths

This used to work. Any idea how to diagnose?

Thomas K
  • 39,200
  • 7
  • 84
  • 86
geotheory
  • 22,624
  • 29
  • 119
  • 196
  • 2
    pip install --upgrade setuptools pip or potentially pip install --upgrade ipython there are a few other quick things to try here https://github.com/jupyter/notebook/issues/270 – bbergvt Apr 07 '16 at 22:54

13 Answers13

16

I had the same issue, fixed by simply using pip install jupyter in the macOS or Ubuntu terminal.

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
Spencer Goff
  • 1,036
  • 3
  • 14
  • 23
10

I faced the same issue, and was able resolve with the following steps.

conda create -n py36 python=3.6
conda activate py36
conda install notebook ipykernel jupyterlab

Naga Budigam
  • 689
  • 1
  • 10
  • 26
  • "conda install notebook ipykernel" is enough if you are using only jupyter notebook. Thanks by the way. It works. – ByUnal Jun 20 '23 at 14:57
3

I have encountered similar issue. Basically, I solved it by uninstall python2.7 and re-install newer python & IPython versions.

Details on how to effectively uninstall python2.7 via Mac OS command line is here: How to uninstall Python 2.7 on a Mac OS X 10.6.4?

Re-install desired version of IPython via command line. In my case, I also needed to re-install Jupyter via:

$ pip install jupyter

Good luck.

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
David C.
  • 1,974
  • 2
  • 19
  • 29
  • 2
    I know this is an older answer, but telling people to uninstall python2 isn't a good solution - there are enough programs out there that still require it. Reinstalling jupyter did help in my case, without removing python2 – GeckoGeorge Aug 22 '18 at 08:54
2

If you are using Anaconda, I recommend installing Jupyter to your conda environment using the following:

conda install -c anaconda jupyter

You can then launch Jupyter from the terminal with the following command:

jupyter notebook .
Colonel_Old
  • 852
  • 9
  • 15
1

I met with the similar problem this morning. As I changed the $PYTHONPATH directory in bash_profile. Then I solved by re-specify the python path back to /usr/lib/python2.*. I hope it will help.

American curl
  • 1,259
  • 2
  • 18
  • 21
1

In my case this was because pip, run with sudo, did not set read and execute rights on the files and directories it created under /usr/local/lib/python2.7/dist-packages.

So I used find and chmod to set them, as described there :

cd /usr/local/lib/python2.7/dist-packages
sudo find ./ -type d -exec chmod a+rx {} \;
sudo find ./ -type f -exec chmod a+r {} \;

In fact, this behaviour of sudo probably arises from the fact that my standard user umask is 0007 (creating private files by default). This seems to transfer to sudo. To avoid this, one can edit the sudo configuration by running sudo visudo and adding the following lines, as per this answer :

Defaults umask_override
Defaults umask=0022
ysalmon
  • 142
  • 8
  • While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Alex Riabov Oct 05 '18 at 11:26
1

(although quite late to the party but) You mentioned that 'it used to work' and from your prompt it looks like you're not in your 'virtual environment'. Simply activate your proper virtual environment to have it work like before.

adhg
  • 10,437
  • 12
  • 58
  • 94
1

just using pip install jupyter while my environment was active worked for me

Omar Hatem
  • 26
  • 4
1

I solved this issue in my environment by uninstalling and then reinstalling jupyter notebook. After that, worked like a charm. While your environment is active, run:

pip uninstall jupyter notebook

pip install jupyter notebook
rob
  • 239
  • 2
  • 10
1

Spoiler: not the cleanest solution but just a workaround.

I had the same issue on Linux (Fedora) caused by the launcher in ~/.local/bin/jupyter due to different versions installed globally and from conda. So I jusst used this workaround (from terminal with conda env) wich worked fine in my case:

python3 -m jupyter notebook
Innuendo
  • 631
  • 5
  • 9
1

https://github.com/dunovank/jupyter-themes/issues/153#issuecomment-1446026919

This post (using conda-forge, as https://jupyter.org/install recommends without showing how)

https://towardsdatascience.com/how-to-set-up-anaconda-and-jupyter-notebook-the-right-way-de3b7623ea4a

Basically it's:

conda create -n jupyter
conda activate jupyter

conda config --add channels conda-forge
conda config --set channel_priority strict
The following is the key (-c conda-forge)

conda install -c conda-forge notebook
conda install -c conda-forge nb_conda_kernels

conda install -c conda-forge jupyterlab
conda install -c conda-forge nb_conda_kernels
james
  • 760
  • 1
  • 9
  • 21
0

It happens when you have multiple versions of Python in your system. Try to find the correct version by looking in the 'pip' directory:

which pip

For me, it was located in:

~/bulk/Python/python-3.7.4/bin/

There, you should be able to find the jupyter executable:

$ ls jupyter
jupyter

Try to run it directly by:

./jupyter

Hope this helps.

Amin.A
  • 164
  • 2
  • 13
-5

Got similar issue & Fixed after removing the user from the sudo group in ubuntu.

sudo deluser my_user sudo
  • 2
    this is poentially dangerous, if e.g. one would remove his (only user) from sudo, and at the same time forgot password to his root account, then admininstrative access to the OS would be irretrievably lost – Marcin Feb 28 '21 at 18:37
  • Try to avoid suggesting the solution with the use of sudo since this is the question by the user, not the administrator. – High Performance Rangsiman Jul 07 '21 at 11:26