passion
passion

Reputation: 1020

jupyter error ImportError: cannot import name path

I get an error when launching python notebook on jupyter:

    Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/connect.py", line 14, in <module>
    from IPython.paths import get_ipython_dir
ImportError: No module named paths

Here is the list of my kernels:

martiner@devubuntu:~$ jupyter kernelspec list
Available kernels:
  javascript    /home/martiner/.local/share/jupyter/kernels/javascript
  python2       /usr/local/share/jupyter/kernels/python2

and here is some other info:

martiner@devubuntu:~$ jupyter kernelspec list
Available kernels:
  javascript    /home/martiner/.local/share/jupyter/kernels/javascript
  python2       /usr/local/share/jupyter/kernels/python2
martiner@devubuntu:~$ cat /usr/local/lib/python2.7/dist-packages/*.pth
    import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('backports',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('backports', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('backports', [os.path.dirname(p)])));m = m or sys.modules.setdefault('backports', types.ModuleType('backports'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
import sys; sys.__plen = len(sys.path)
./SOMPY-1.0-py2.7.egg
./numexpr-2.6.1-py2.7-linux-x86_64.egg
/usr/lib/python2.7/dist-packages
import sys; new = sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p = getattr(sys, '__egginsert', 0); sys.path[p:p] = new; sys.__egginsert = p + len(new)

update

this is working only when I run:

ipython notebook

but if I run :

jupyter-notebook

and then open a notebook, i get the kernel error.

Upvotes: 1

Views: 4211

Answers (1)

Dwijay Bane
Dwijay Bane

Reputation: 118

This is because of version conflict of ipython installed by apt-get package manager and ipython by pip:

so uninstall all versions of ipython from apt-get as follows:

sudo apt-get remove ipython ipython-notebook ipython-notebook-common

also remove from pip: both jupyter and ipython

sudo pip uninstall jupyter 
sudo pip uninstall ipython  

As ipython is part of jupyter, so just reinstall jupyter

sudo pip install jupyter 

This should help!!!

Upvotes: 1

Related Questions