如何修复anaconda中的导入路径?

时间:2017-02-06 10:53:16

标签: python python-2.7 path anaconda conda

我的朋友的Conda在密集尝试安装FEniCS DOLFIN后停止工作。 Anaconda已安装在朋友的$HOME/anaconda目录中(目录已添加到$PATH)。删除目录并在新位置安装并没有解决问题:

$ conda info
Traceback (most recent call last):
  File "/home/user/anaconda2/bin/conda", line 4, in <module>
    import conda.cli
  File "/home/user/anaconda2/lib/python2.7/site-packages/conda/cli/__init__.py", line 8, in <module>
    from .main import main  # NOQA
  File "/home/user/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 46, in <module>
    from ..base.context import context
  File "/home/user/anaconda2/lib/python2.7/site-packages/conda/base/context.py", line 20, in <module>
    from ..common.url import urlparse, path_to_url
  File "/home/user/anaconda2/lib/python2.7/site-packages/conda/common/url.py", line 17, in <module>
    from requests.packages.urllib3.util.url import parse_url
ImportError: No module named packages.urllib3.util.url

然而/home/user/anaconda2/lib/python2.7/site-packages/requests/packages/urllib3/util/url.py已经存在。

我试图检查sys.pathipythonpython)。结果是:

['',
 '/home/user/anaconda2/bin',
 '/usr/lib/python2.7/dist-packages',
 '/home/user/anaconda2/lib/python27.zip',
 '/home/user/anaconda2/lib/python2.7',
 '/home/user/anaconda2/lib/python2.7/plat-linux2',
 '/home/user/anaconda2/lib/python2.7/lib-tk',
 '/home/user/anaconda2/lib/python2.7/lib-old',
 '/home/user/anaconda2/lib/python2.7/lib-dynload',
 '/home/user/.local/lib/python2.7/site-packages',
 '/home/user/anaconda2/lib/python2.7/site-packages',
 '/home/user/anaconda2/lib/python2.7/site-packages/Sphinx-1.4.6-py2.7.egg',
 '/home/user/anaconda2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg',
 '/usr/lib/python2.7/dist-packages/IPython/extensions']

请注意列表中的第3个(/usr/lib/python2.7/dist-packages)和最后一个(/usr/lib/python2.7/dist-packages/IPython/extensions)元素。我怀疑它是导致麻烦的原因,因为sys.path我的(工作正常)Anaconda没有提到/usr/lib

我朋友的其他Anaconda工具似乎也受到了影响:

$ ~/anaconda2/bin/pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages
Cleaning up...

我找到了类似(未答复)的问题conda missing requests.packages.urllib3.util.url,但目前还不清楚,那里sys.path的内容是什么。 还有How to fix ImportError: No module named packages.urllib3? - 但那里没有提到蟒蛇。

[编辑]

问题不在全系统范围内 - 在我的帐户中,我成功安装了Anaconda并且工作正常。 sys.path中也没有可疑条目。

[编辑]

绝望的时候需要绝望的措施。问题是 fixed 走了arround,删除了朋友的主目录。

0 个答案:

没有答案