When I try to export one of my environments using conda env export -n torch > torch.yml
I get the following error:
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'
Output for 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
Output for 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
Output for 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')
The conda version that I'm currently using is 4.13.0 and I'm on Ubuntu 20.04.4 with kernel version 5.13.0-44-generic.
I tried to export other environments as well and had the same problem with them too.
I have also tried to uninstall "attr" and install "attrs" via pip but it didn't have any affect on the situation.
CodePudding user response:
The problem here is side-loading from user site, which can be seen by how Python has resolved the attr
module:
'/home/onatgirit/.local/lib/python3.8/site-packages/attr.py'
Not sure what is in that file, but it is masking the attr
module that is expected to be provided by attrs
packages.
Several options to resolve this can be found in this answer. For this particular case, if you are not deliberately using the user site, I would recommend removing all ~/.local/lib/python*
directories (i.e., everything installed with pip install --user
). Otherwise, the simplest solution is probably to do:
conda install -n base conda-forge::conda-ecosystem-user-package-isolation