[英]jupyter error ImportError: cannot import name path
I get an error when launching python notebook on jupyter: 在jupyter上启动python笔记本时出现错误:
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)
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. 然后打开一个笔记本,我得到内核错误。
This is because of version conflict of ipython installed by apt-get package manager and ipython by pip: 这是因为apt-get软件包管理器安装的ipython和pip的ipython版本冲突:
so uninstall all versions of ipython from apt-get as follows: 因此,请按照以下步骤从apt-get卸载所有版本的ipython:
sudo apt-get remove ipython ipython-notebook ipython-notebook-common
also remove from pip: both jupyter and ipython 也从点子中删除:jupyter和ipython
sudo pip uninstall jupyter
sudo pip uninstall ipython
As ipython is part of jupyter, so just reinstall jupyter 由于ipython是jupyter的一部分,因此只需重新安装jupyter
sudo pip install jupyter
This should help!!! 这应该有所帮助!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.