2016-12-29 80 views
5

Conda在我使用它運行任何命令時發生錯誤。Conda'ImportError:No module named ruamel.yaml.comments'

Traceback (most recent call last): 
    File "/usr/local/bin/conda", line 7, in <module> 
    from conda.cli.main import main 
    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 
+0

檢查是否有幫助:http://stackoverflow.com/questions/40733906/python-conda-traceback-no-module-named-ruamel-yaml-comments – MYGz

+0

@MYGz已經試過這個。 –

+0

如果ruamel包存在或不存在,您可以在系統中遞歸搜索嗎? – MYGz

回答

7

模塊ruamel.yaml.comments,通常爲site-packages/ruamel/yaml/comments.py加載,而不是從site-packages/ruamel_yaml/comments.py

康達似乎與正確支持命名空間(ruamel.),我只能歸因於(還)沒有被完全pip問題兼容。儘管"namespaces are a honking good idea"和包名稱空間已經存在很多年了。

假設你可以擴展與pip「暢達」的安裝,你可以嘗試做的ruamel.yaml正常安裝:

pip install ruamel_yaml==0.11.14 

通常我不會建議這樣的舊版本,但更可能的工作結合conda版本使用它自己的內部。

另一種方法是切換到不使用conda的python和pip,這樣你就可以使用PyPI的最新版本的軟件。

+0

你的公司和ruamel包有任何關係嗎? :) – MYGz

+0

@MYGz是的,Ruamel bvba,是100%贊助的發展。由於我不是在推銷我自己的軟件包作爲解決某些尚未涉及'ruamel.yaml'的問題的解決方案,所以我沒有考慮放入免責聲明。 – Anthon

+0

不錯。我只是好奇而已。這個問題與多次安裝anaconda有關。他可能在安裝完整軟件包之前首先安裝了miniconda。 – MYGz

0

以上答案對我無效。我必須按照conda文檔here中的描述重新安裝核心conda組件。複製和粘貼下面:

Issue: My conda is broken and I want to fix it without blowing away the current installation I am getting a conda error and want to reinstall Miniconda to fix it but when I try, it gives me the error that Miniconda (or Anaconda) is already installed and will not let me continue. I want to force the installation.

Resolution: Install Miniconda using the -f (force) option Download and install the appropriate Miniconda for your computer operating system from the Miniconda download page using the force or -f option as shown:

bash Miniconda3-latest-MacOSX-x86_64.sh -f 

NOTE: Substitute the appropriate filename and version for your operating system.

NOTE: Be sure that you install to same install location as your existing install so it overwrites the core conda files and does not install a duplicate in a new folder.

4

嘗試sudo pip install ruamel_yaml

4

嘗試pip install ruamel.yaml

這對我的作品。

1

我走進這個文件:

/anaconda2/lib/python2.7/site-packages/dateparser/utils/__init__.py 

編輯這一行:

import ruamel.yaml as yaml 

閱讀

import ruamel_yaml as yaml 

點更改爲下劃線爲我工作....我希望這個對你有用。