安装 iPython:“ImportError 无法导入名称路径”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32252122/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing iPython: "ImportError cannot import name path"?
提问by Richard
I'm trying to install IPython. I have run pip install ipython[notebook]
without any errors, but now I get this:
我正在尝试安装 IPython。我已经运行pip install ipython[notebook]
没有任何错误,但现在我明白了:
$ ipython notebook
Traceback (most recent call last):
File "/Users/me/.virtualenvs/.venv/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .terminal.embed import embed
File "/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
File "/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/pickleshare.py", line 41, in <module>
from path import path as Path
ImportError: cannot import name path
I have the same error if I try to run import pickleshare
at a Python console, or from path import path
.
如果我尝试import pickleshare
在 Python 控制台或from path import path
.
What can I do to fix this?
我能做些什么来解决这个问题?
采纳答案by fatz
Looks like this is a known issue, caused by a change in the path.py
package. Reverting to an older version of path.py
solves this :
看起来这是一个已知问题,由path.py
包中的更改引起。恢复到旧版本path.py
可以解决这个问题:
sudo pip3 install -I path.py==7.7.1
回答by Sudeep Juvekar
It appears that pickleshare
is in package IPython.utils
. Try tying
看起来pickleshare
是在包中IPython.utils
。尝试绑
from IPython.utils.pickleshare import PickleShareDB
Similarly, path
is in IPython.external
. Try typing
同样,path
在IPython.external
. 尝试打字
from IPython.external.path import path as Path
In either case, I would check if following files exist.
无论哪种情况,我都会检查以下文件是否存在。
"/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/utils/pickleshare.py"
"/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/external/path/_path.py"
All this points to the fact that probably your IPython/notebook version is old. A couple of solutions would be
所有这些都表明您的 IPython/notebook 版本可能很旧。几个解决方案是
1) Try editing files in site-packages and changing import lines to
1)尝试编辑站点包中的文件并将导入行更改为
from IPython.external.path import path as Path
from IPython.utils.pickleshare import PickleShareDB
But that's kind of risky, who knows what else might fail.
但这有点冒险,谁知道还有什么可能会失败。
Otherwise, try upgrading ipython/notebook
否则,尝试升级 ipython/notebook
pip install ipython --upgrade
pip install "ipython[notebook]" --upgrade
回答by Brian Spiering
I had similar issues and rolling back to an earlier version of path.py
did not not help. I uninstalled the package and then IPython Notebook worked.
我遇到了类似的问题,回滚到早期版本path.py
也无济于事。我卸载了这个包,然后 IPython Notebook 工作了。
pip uninstall -y path.py
pip uninstall -y path.py
回答by Colton Neary
I received this error while trying to import matplotlib on Windows 10. My problem was that matplotlib needed an update. I just ran the following code:
我在 Windows 10 上尝试导入 matplotlib 时收到此错误。我的问题是 matplotlib 需要更新。我刚刚运行了以下代码:
python -m pip install matplotlib
or:
或者:
conda install matplotlib
My guess is that this can be applied to IPython.
我的猜测是这可以应用于 IPython。