An unexpected error has occurred. Conda has prepared the above report.输入任意Conda指令报错。

本文讲述了在Ubuntu环境下遇到的Conda错误,涉及ruamel.yaml调用失败。作者提供了详细的解决步骤,包括检查conda配置、修改环境变量、修复文件权限、安装缺失的ruamel包等,最终成功解决问题。
摘要由CSDN通过智能技术生成

1.问题描述(建议看一下是否是自己的问题)

当进入Ubuntu环境时,调用conda info --envs 命令查看已有conda环境时,出现以下错误。

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/star/envs/lib/python3.7/site-packages/conda/cli/main.py", line 97, in main
        from ..activate import main as activator_main
      File "/home/star/envs/lib/python3.7/site-packages/conda/activate.py", line 15, in <module>
        context.__init__()  # oOn import, context does not include SEARCH_PATH. This line fixes that.
      File "/home/star/envs/lib/python3.7/site-packages/conda/base/context.py", line 237, in __init__
        argparse_args=argparse_args)
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 722, in __init__
        self._set_search_path(search_path)
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 728, in _set_search_path
        self._set_raw_data(load_file_configs(search_path))
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 369, in load_file_configs
        raw_data = odict(kv for kv in chain.from_iterable(load_paths))
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 369, in <genexpr>
        raw_data = odict(kv for kv in chain.from_iterable(load_paths))
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 344, in _file_yaml_loader
        yield fullpath, YamlRawParameter.make_raw_parameters_from_file(fullpath)
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/configuration.py", line 332, in make_raw_parameters_from_file
        ruamel_yaml = yaml_load(fh)
      File "/home/star/envs/lib/python3.7/site-packages/conda/common/serialize.py", line 54, in yaml_load
        return yaml.load(string, Loader=yaml.RoundTripLoader, version="1.2")
      File "/home/star/envs/lib/python3.7/site-packages/ruamel/yaml/main.py", line 1085, in load
        error_deprecation('load', 'load', arg=_error_dep_arg, comment=_error_dep_comment)
      File "/home/star/envs/lib/python3.7/site-packages/ruamel/yaml/main.py", line 1037, in error_deprecation
        raise AttributeError(s)
    AttributeError: 
    "load()" has been removed, use
    
      yaml = YAML(typ='rt')
      yaml.load(...)
    
    and register any classes that you use, or check the tag attribute on the loaded data,
    instead of file "/home/star/envs/lib/python3.7/site-packages/conda/common/serialize.py", line 54
    
        return yaml.load(string, Loader=yaml.RoundTripLoader, version="1.2")
    
    

`$ /home/star/envs/bin/conda shell.posix activate base`

  environment variables:
                 CIO_TEST=<not set>
          CONDA_CHANGEPS1=true
                CONDA_EXE=/home/star/envs/bin/conda
               CONDA_HOME=/home/star/envs
             CONDA_PREFIX=/home/star/envs
             CONDA_PYTHON=/home/star/envs/bin/python
         CONDA_PYTHON_EXE=/home/star/envs/bin/python
               CONDA_ROOT=/home/star/envs
              CONDA_SHLVL=0
          LD_LIBRARY_PATH=/usr/local/cuda/lib64
                     PATH=/home/star/envs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
                          /sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/star/data/cxy/n
                          ode-v18.18.0-linux-x64/bin:/home/star/envs/bin:/home/star/envs/bin/con
                          da:/home/star/envs:/home/star/envs/bin/python:/home/star/envs/bin/pyth
                          on:/usr/local/cuda/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : base
    active env location : /home/star/envs
            shell level : 0
       user config file : /home/star/.condarc
 populated config files : 
          conda version : 4.5.11
    conda-build version : 3.15.1
         python version : 3.7.0.final.0
       base environment : /home/star/envs  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /home/star/envs/pkgs
                          /home/star/.conda/pkgs
       envs directories : /home/star/envs/envs
                          /home/star/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.11 requests/2.31.0 CPython/3.7.0 Linux/5.15.0-88-generic ubuntu/20.04 glibc/2.31
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
[y/N]: 
No report sent. To permanently opt-out, use

    $ conda config --set report_errors false

通过报错信息得知,错误的点存在以下两个:

  • 关于ruamel.yaml的调用错误
AttributeError: 
    "load()" has been removed, use
    
      yaml = YAML(typ='rt')
      yaml.load(...)
    
    and register any classes that you use, or check the tag attribute on the loaded data,
    instead of file "/home/star/envs/lib/python3.7/site-packages/conda/common/serialize.py", line 54
    
        return yaml.load(string, Loader=yaml.RoundTripLoader, version="1.2")
  • conda命令发生预期之外的错误
An unexpected error has occurred. Conda has prepared the above report

另外,日常正确的加载情况应该如下,直接激活conda的base环境,如下所示。但是报错的时候并没有(base)

(base) star@b404-3090:~$

2. 解决办法

注:我的conda安装目录是/home/star/envs 请自行比对

第一步:通过以下命令检查conda相关信息

export

返回信息如下所示:

(base) star@b404-3090:~$ export
declare -x CONDA_DEFAULT_ENV="base"
declare -x CONDA_EXE="/home/star/envs/bin/conda"
declare -x CONDA_HOME="/home/star/envs"
declare -x CONDA_PREFIX="/home/star/envs"
declare -x CONDA_PROMPT_MODIFIER="(base) "
declare -x CONDA_PYTHON="/home/star/envs/bin/python"
declare -x CONDA_PYTHON_EXE="/home/star/envs/bin/python"
declare -x CONDA_SHLVL="1"
declare -x CUDA_VISIBLE_DEVICES="0,1,2"

请确认以上有关CONDA的字段指向的路径是你conda正确安装的路径。再次强调,我的conda安装路径是/home/star/envs,请自己比对后修改以上字段。

第二步:通过以下命令修改不正确的字段

# vim 是编辑器,如果有其他的编辑器例如nano也可以使用
sudo vim /etc/profile

# 然后再/etc/profile文件中添加需要修改的内容,根据自己的实际情况
export NODE_HOME=/home/star/data/cxy/node-v18.18.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export CONDA_HOME=/home/star/envs
export PATH=$PATH:$CONDA_HOME/bin
export CONDA_EXE=/home/star/envs/bin/conda
export PATH=$PATH:$CONDA_EXE
export CONDA_PREFIX=/home/star/envs
export PATH=$PATH:$CONDA_PREFIX
export CONDA_PYTHON=/home/star/envs/bin/python

# 修改完毕后,输入以下命令使其生效
source /etc/profile

# 使用export 再次查看更改是否生效

小插曲

我更改完环境变量后,在export命令返回的内容中是正确的,但是使用conda命令时出现

-bash: /home/star/anaconda3/bin/conda: 没有那个文件或目录

这是因为我的服务器中安装了两个anaconda,这个anaconda3是后面安装的,也许覆盖掉了之前的安装路径,但是我也找不到它具体是哪个变量绑定的,所以通过别名的方式进行修改,如果你也有一样的问题,可以尝试

# 注 envs是我最早安装的,anaconda3是后面安装的,所以这条指令的目的是使得conda指向最初的envs安装目录。
alias conda='/home/star/envs/bin/conda'

第三步: 确保文件有执行权限

# 使用以下指令添加权限
chmod +x /home/star/envs/bin/conda

第四步:检查是否存在ruamel包

# 如果看见了ruamel那就是已经有了,但是报错一般来说是没有的
conda list | grep "ruamel"

第四步:下载ruamel文件

打开链接:ruamel下载
由于服务器当前处于断网的情况,所以我是通过在本地下载之后,通过Xftp上传到服务器的。如果你的服务器连接了网络,那么你可以通过wget 或者curl命令下载

第五步: 安装ruamel文件

使用mv命令将第四步下载的ruamel文件移动到conda安装目录下的bin目录中,我的是/home/star/envs/bin,请自行比对,移动完毕后,通过pip install 下载的文件名.whl命令进行安装。

第六步:查看是否安装成功

(base) star@b404-3090:~$ conda list |grep "ruamel"
ruamel.yaml               0.17.21                   <pip>
ruamel.yaml.clib          0.2.8                     <pip>
ruamel_yaml               0.15.46          py37h14c3975_0    https://repo.anaconda.com/pkgs/main

安装成功!到此,重新连接,就会发现再次进入时已经没有报错,并且初始是base环境~

3. 致谢

感谢热心市民BIN!!!

  • 20
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当安装PyTorch时出现"An unexpected error has occurred. Conda has prepared the above report."的错误报告时,这通常意味着安装过程中遇到了一些问题。根据引用的内容,可以看到有一些方法可以尝试解决这个问题。 首先,可以尝试使用conda clean命令来清理缓存。这可以通过运行"conda clean -i"来完成。但是根据引用的说法,这个方法可能并不总是有效。 另一种方法是创建一个新的环境,并在新环境中安装PyTorch。这可以通过运行以下命令来实现: conda create -n myenv conda activate myenv conda install pytorch 这种方法可能需要下载许多软件包,因此可能比较耗时。但是根据引用的说法,这个方法是有效的。 总结来说,当安装PyTorch时出现"An unexpected error has occurred. Conda has prepared the above report."的错误报告时,可以尝试使用conda clean命令清理缓存,或者创建一个新的环境并在该环境中安装PyTorch。希望这些方法能够解决你的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [conda报错记录An unexpected error has occurred. Conda has prepared the above report.](https://blog.csdn.net/hjliu_happy/article/details/126710030)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [anconda安装pytorch失败An unexpected error has occurred. Conda has prepared the above report解决](https://blog.csdn.net/bigfishfish/article/details/120460704)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值