Python conda traceback: No module named ruamel.yam

2019-09-18 09:45发布

Ran conda update conda on bash terminal and below is the traceback.

Any idea on what is wrong with my installation?

yusuf@yusuf-pc2:~$ conda update conda
Traceback (most recent call last):
  File "/usr/local/bin/conda", line 11, in <module>
    load_entry_point('conda==4.2.7', 'console_scripts', 'conda')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 567, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2612, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2272, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2278, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/conda/cli/__init__.py", line 8, in <module>
    from .main import main  # NOQA
  File "/usr/local/lib/python2.7/dist-packages/conda/cli/main.py", line 46, in <module>
    from ..base.context import context
  File "/usr/local/lib/python2.7/dist-packages/conda/base/context.py", line 18, in <module>
    from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
  File "/usr/local/lib/python2.7/dist-packages/conda/common/configuration.py", line 40, in <module>
    from ruamel.yaml.comments import CommentedSeq, CommentedMap  # pragma: no cover
ImportError: No module named ruamel.yaml.comments
yusuf@yusuf-pc2:~$ 

Location of ruamel package:

/home/yusuf/anaconda2/lib/python2.7/site-packages/ruamel_yaml/comments.py
/home/yusuf/anaconda2/lib/python2.7/site-packages/ruamel_yaml/comments.pyc

The path needs to be corrected. Any idea on how to fix it?

1条回答
狗以群分
2楼-- · 2019-09-18 09:46

Got a solution from Argonauts (superuser.com):

It looks like you have two instances of anaconda installed on your system. One installed to /usr/local/ and the other to your home directory.

From the bash shell, modify your path (temporarily) with this command:

export PATH="/home/yusuf/anaconda2/bin:$PATH"

Then try updating again:

conda update conda

That should resolve the issue. You can then add the export PATH... line to the bottom of your ~/.bashrc file and the fix will be persistent.

Assuming that I guessed correctly about the cause of this issue, you'll want to remove the duplicate installation - as long no other system users are using it.

To clean up the duplicate installation issue, under normal circumstances you can remove an unwanted anaconda install simply by deleting it - however since you have it installed to /usr/local/ you will need to be very careful - other applications may be installed to that directory. Simply renaming /usr/local/bin/conda to /usr/local/bin/old.conda and the same for each /usr/local/bin/python* entry shoud be enough to prevent that install being used, but it's far from a perfect solution.

Source: https://superuser.com/questions/1159792/conda-traceback-no-module-named-ruamel-yaml-comments

查看更多
登录 后发表回答