gpt4 book ai didi

python - 导出 conda 环境时出现 AttributeError

转载 作者:行者123 更新时间:2023-12-04 18:47:59 32 4
gpt4 key购买 nike

当我尝试使用 conda env export -n torch > torch.yml 导出我的一个环境时我收到以下错误:

Traceback (most recent call last):
File "/home/onatgirit/anaconda3/bin/conda-env", line 6, in <module>
from conda_env.cli.main import main
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/conda_env/cli/main.py", line 44, in <module>
from . import main_create
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/conda_env/cli/main_create.py", line 20, in <module>
from .. import specs
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/conda_env/specs/__init__.py", line 15, in <module>
from .notebook import NotebookSpec
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/conda_env/specs/notebook.py", line 5, in <module>
import nbformat
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/nbformat/__init__.py", line 11, in <module>
from . import v1, v2, v3, v4
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/nbformat/v4/__init__.py", line 39, in <module>
from .convert import downgrade, upgrade
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/nbformat/v4/convert.py", line 13, in <module>
from .. import validator
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/nbformat/validator.py", line 13, in <module>
from .json_compat import ValidationError, _validator_for_name, get_current_validator
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/nbformat/json_compat.py", line 11, in <module>
import jsonschema
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/jsonschema/__init__.py", line 12, in <module>
from jsonschema._format import (
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/jsonschema/_format.py", line 10, in <module>
from jsonschema.exceptions import FormatError
File "/home/onatgirit/anaconda3/lib/python3.8/site-packages/jsonschema/exceptions.py", line 158, in <module>
@attr.s(hash=True)
AttributeError: module 'attr' has no attribute 's'
conda info 的输出:
     active environment : None
shell level : 0
user config file : /home/onatgirit/.condarc
populated config files : /home/onatgirit/.condarc
conda version : 4.13.0
conda-build version : 3.20.5
python version : 3.8.13.final.0
virtual packages : __cuda=11.6=0
__linux=5.13.0=0
__glibc=2.31=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/onatgirit/anaconda3 (writable)
conda av data dir : /home/onatgirit/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/onatgirit/anaconda3/pkgs
/home/onatgirit/.conda/pkgs
envs directories : /home/onatgirit/anaconda3/envs
/home/onatgirit/.conda/envs
platform : linux-64
user-agent : conda/4.13.0 requests/2.27.1 CPython/3.8.13 Linux/5.13.0-44-generic ubuntu/20.04.4 glibc/2.31
UID:GID : 1000:1000
netrc file : None
offline mode : False
conda list -n base '(nbformat|jsonschema|attr)' 的输出:
    # packages in environment at /home/onatgirit/anaconda3:
#
# Name Version Build Channel
attrs 21.4.0 pyhd3eb1b0_0
jsonschema 4.4.0 py38h06a4308_0
nbformat 5.3.0 py38h06a4308_0
python-fastjsonschema 2.15.1 pyhd3eb1b0_0
conda run -n base python -c 'import attr; print(attr.__spec__)' 的输出:
ModuleSpec(name='attr', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fd32b603160>, origin='/home/onatgirit/.local/lib/python3.8/site-packages/attr.py')
我目前使用的 conda 版本是 4.13.0,我使用的是内核版本为 5.13.0-44-generic 的 Ubuntu 20.04.4。
我也尝试导出其他环境,并且也遇到了同样的问题。
我也尝试通过 pip 卸载“attr”并安装“attrs”,但它对这种情况没有任何影响。

最佳答案

这里的问题是从用户站点侧加载,这可以从 Python 如何解决 attr 中看出。模块:

'/home/onatgirit/.local/lib/python3.8/site-packages/attr.py'
不确定该文件中有什么,但它掩盖了 attr预计由 attrs 提供的模块包。
可以在 this answer 中找到解决此问题的几个选项。 .对于这种特殊情况,如果您不是故意使用用户站点,我建议您删除所有 ~/.local/lib/python*目录(即使用 pip install --user 安装的所有内容)。否则,最简单的解决方案可能是:
conda install -n base conda-forge::conda-ecosystem-user-package-isolation

关于python - 导出 conda 环境时出现 AttributeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72519572/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com