Error running a fresh install of iPython

我只是一个虾纸丫 提交于 2019-12-10 14:51:35

问题


I am using virtualenvwrapper so anybody can reproduce it easily, but this happens as well using pip directly on my system.

After installing iPython with pip, I wont be able to run it (note I'm using the Python 2 interpreter, although the same exact thing will happen if I use Python 3):

$ mkvirtualenv -p python2 test
$ pip install --upgrade pip      # Just in case...
$ pip install ipython
$ ipython
Traceback (most recent call last):
  File "/home/peque/.virtualenvs/test/bin/ipython", line 7, in <module>
    from IPython import start_ipython
  File "/home/peque/.virtualenvs/test/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
    from .terminal.embed import embed
  File "/home/peque/.virtualenvs/test/lib/python2.7/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.core.interactiveshell import DummyMod
  File "/home/peque/.virtualenvs/test/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 31, in <module>
    from pickleshare import PickleShareDB
  File "/home/peque/.virtualenvs/test/lib/python2.7/site-packages/pickleshare.py", line 41, in <module>
    from path import path as Path
ImportError: cannot import name path

Now, the packages I have installed after this simple steps are:

$ pip freeze
decorator==4.0.2
ipython==4.0.0
ipython-genutils==0.1.0
path.py==8.0
pexpect==3.3
pickleshare==0.5
simplegeneric==0.8.1
traitlets==4.0.0

Why am I getting this error? Is there any way to avoid it while still using iPython version 4?


回答1:


Quick fix

Just downgrade package:

pip install -I path.py==7.7.1

Explanation

There is a commit (62ccb76) made a couple of hours ago that removes the path alias and bumps path.py version to 0.8. Apparently, in order to fix Issue #102:

Removed path.path. Clients must now refer to the canonical name, path.Path as introduced in 6.2.

However, pickleshare has not been updated and continues to use the old alias.

The problem has already been reported, and hope it will be fixed soon. I created a pull request in case it helps.

Update

The pull request has already been merged and version 8.1 of path.py adds the path alias again (a warning will be generated instead for now). So users should not hit this problem now.

Updating the package to version 8.1 should fix the problem as well now:

pip install -I path.py==8.1



回答2:


Your import looks incorrect, https://pypi.python.org/pypi/path.py

from path import Path



回答3:


You might have an Ipython installed system wide. Just run workon test before starting ipython.



来源:https://stackoverflow.com/questions/32252915/error-running-a-fresh-install-of-ipython

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!