conda
conda copied to clipboard
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
Current Behavior
conda commands crash after upgrade ruamel.yaml to latest version using pip (0.15.75 as for this issue sent)
Steps to Reproduce
<<< conda env
>>>
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\Scripts\conda-env-script.py", line 6, in <module>
from conda_env.cli.main import main
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda_env\cli\main.py", line 6, in <module>
from conda.base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
Expected Behavior
shouldn't crash
Environment Information
`conda info`
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 73, in _main
from ..base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 113, in main
return conda_exception_handler(_main, *args)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 1108, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 822, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 862, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 873, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 928, in print_unexpected_error_report
from .base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
`conda config --show-sources`
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 73, in _main
from ..base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 113, in main
return conda_exception_handler(_main, *args)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 1108, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 822, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 862, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 873, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 928, in print_unexpected_error_report
from .base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
`conda list --show-channel-urls`
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 73, in _main
from ..base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SLAPaper\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\cli\main.py", line 113, in main
return conda_exception_handler(_main, *args)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 1108, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 822, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 862, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 873, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\exceptions.py", line 928, in print_unexpected_error_report
from .base.context import context
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\base\context.py", line 23, in <module>
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\configuration.py", line 34, in <module>
from .serialize import yaml_load
File "C:\Users\SLAPaper\Miniconda3\lib\site-packages\conda\common\serialize.py", line 42, in <module>
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict)
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
Did the same today, wanted to update packages from pip which are not in conda. So the problem was the following: The package in PYPI ist listed as ruamel-yaml, in conda it is ruamel_yaml. So actually it shouldn't have been found when the name would have been identically.
To get around this annoying issue, go to site-packages, delete all ruamel_yaml and install with pip:
pip install ruamel_yaml==0.15.71
However, unfortunately you can't restore the conda-version of ruamel_yaml directly.
(base) C:\>conda install -f ruamel_yaml
WARNING: The --force flag will be removed in a future conda release.
See 'conda install --help' for details about the --force-reinstall
and --clobber flags.
Collecting package metadata: done
Solving environment: done
## Package Plan ##
environment location: C:\Anaconda3
added / updated specs:
- ruamel_yaml
The following packages will be downloaded:
package | build
---------------------------|-----------------
blas-1.0 | mkl 6 KB
clangdev-5.0.0 | flang_3 189.0 MB conda-forge
------------------------------------------------------------
Total: 189.0 MB
The following NEW packages will be INSTALLED:
ruamel_yaml conda-forge/win-64::ruamel_yaml-0.15.71-py37hfa6e2cd_1000
The following packages will be UPDATED:
blas conda-forge --> pkgs/main
The following packages will be DOWNGRADED:
clangdev 7.0.0-h014eb38_1000 --> 5.0.0-flang_3
Proceed ([y]/n)?
Downloading and Extracting Packages
clangdev-5.0.0 | 189.0 MB | ################################################################################################################################################################################################# | 100%
blas-1.0 | 6 KB | ################################################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: failed
RemoveError: 'ruamel_yaml' is a dependency of conda and cannot be removed from
conda's operating environment.
@kalefranz , why not, could you tell? Inplace upgrade/restore should be possible always. If there is another way like
conda install -f conda
(base) C:\>conda install -f conda
WARNING: The --force flag will be removed in a future conda release.
See 'conda install --help' for details about the --force-reinstall
and --clobber flags.
Collecting package metadata: done
Solving environment: done
## Package Plan ##
environment location: C:\Anaconda3
added / updated specs:
- conda
The following NEW packages will be INSTALLED:
ruamel_yaml conda-forge/win-64::ruamel_yaml-0.15.71-py37hfa6e2cd_1000
The following packages will be UPDATED:
blas conda-forge --> pkgs/main
The following packages will be DOWNGRADED:
clangdev 7.0.0-h014eb38_1000 --> 5.0.0-flang_3
Proceed ([y]/n)?
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
it should at least be suggested in the error above. Actually it is very hard to repair/restore such a broken conda-installation to default. This should be much easier.
I face the same problem. Maybe something is worse, because when trying to install ruamel_yaml I get response
pip is not recognized as an internal or external command
Any conda commands seem return this error.
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
So I cannot use the rollback func of conda to restore the past conda. I feel upset.
Any suggestions and questions wil be helpful.
@CinderellaRobaker
Did you find any solution for this. I am facing the same issue. No solutions on google either
@pratikbijam Same to you. It seems no solution can work out. To be honest, I reinstall Anaconda.
@pratikbijam 和你一样。似乎没有解决办法。老实说,我重新安装了Anaconda。
Mabey I should reinstall it too...
Just updated to conda 4.7.10 from v4.7.9, and now I'm getting this error with all conda sub-commands (eg., conda help
or conda create
). It's pretty bad if just updating conda causes it to completely break.
To get around this annoying issue, go to site-packages, delete all ruamel_yaml and install with pip:
This assumes that you have pip
already installed in the base conda env. Otherwise, pip won't install ruamel_yaml within conda. I love the error that conda throws after deleting the ruamel_yaml*
files in the site packages:
Traceback (most recent call last):
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/common/serialize.py", line 19, in get_yaml
import ruamel_yaml as yaml
ModuleNotFoundError: No module named 'ruamel_yaml'
[...]
To proceed, conda install ruamel_yaml
...but conda install ruamel_yaml
creates exactly the same error message!
I tried just copying the ruamel_yaml* files from a different anaconda install into my broken install, and now when running conda info
, I get the following:
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/exceptions.py", line 1062, in __call__
return func(*args, **kwargs)
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/cli/main.py", line 84, in _main
exit_code = do_call(args, p)
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 80, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/ebio/abt3_projects/software/dev/miniconda3_dev/lib/python3.6/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
ModuleNotFoundError: No module named 'conda_package_handling'
`$ /ebio/abt3_projects/software/dev/miniconda3_dev/bin/conda info`
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]:
Timeout reached. No report sent.
The report can't even be sent. At least conda activate
and most of the conda subcommands work again...
@SLAPaper I am still facing this issue and getting the AttributeError: module 'ruamel_yaml' has no attribute 'representer'
error on Conda Prompt.
Did you find any solution?
@SLAPaper I am still facing this issue and getting the
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
error on Conda Prompt.Did you find any solution?
@daniyalas Reinstallation of Anaconda/Miniconda should work. It has been a long time so my memory might not be correct.
@SLAPaper I am still facing this issue and getting the
AttributeError: module 'ruamel_yaml' has no attribute 'representer'
error on Conda Prompt. Did you find any solution?@daniyalas Reinstallation of Anaconda/Miniconda should work. It has been a long time so my memory might not be correct.
Yeah, I had to reinstall it. Nothing else seemed to work. It's a huge hassle though.
I've run into this bug multiple times over the past year or so when I forget that I "shouldn't ever" update conda. I'm amazed this hasn't been fixed yet.
Still not fixed??
@ishrahussain Probably not.
It's just disappointing.
I ran into same problem and now I am reinstalling conda, and it's really bad
So only can to reinstall?
您好~这里是罗壮的邮箱,我已收到您的来信,会尽快给您回复的,请稍作等待喔~
SOLVED:
Just to say that this is still an issue. My version of the error refers to this path:
/Users/xxxx/miniconda3/lib/python3.8/site-packages/conda/common/serialize.py
The code that is relevant is this. The fix is referred to below. My best guess is that there is a "ruamel_yaml" package out there that still gets loaded and it will cause an error with certainly python 3.8 (and above?). The workaround is to simply not let it look for that package and force it to look for "ruamel.yaml" (ie. no underscore in the name). This is a quick fix not proper code fix.
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import absolute_import, division, print_function, unicode_literals
import json
from logging import getLogger
from .comp-at import PY2, odict, ensure_text_type
from .._vendor.auxlib.decorators import memoize
from .._vendor.auxlib.entity import EntityEncoder
log = getLogger(__name__)
@memoize
def get_yaml(): <========= this gets called below and addresses the _ vs . issue
try:
import ruamel_yaml as yaml <====== SOLVED: modify to read "ruamel.yaml" ... underscore replaced by " . "
except ImportError: # pragma: no cover
try:
import ruamel.yaml as yaml
except ImportError:
raise ImportError("No yaml library available.\n"
"To proceed, conda install "
"ruamel_yaml")
return yaml
yaml = get_yaml() <============= calls the above function
def represent_ordereddict(dumper, data):
value = []
for item_key, item_value in data.items():
node_key = dumper.represent_data(item_key)
node_value = dumper.represent_data(item_value)
value.append((node_key, node_value))
return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
yaml.representer.RoundTripRepresenter.add_representer(odict, represent_ordereddict). <===== throws the error
yaml.representer.SafeRepresenter.add_representer(odict, represent_ordereddict)
您好~这里是罗壮的邮箱,我已收到您的来信,会尽快给您回复的,请稍作等待喔~
conda dropped ruamel_yaml (ruamel underscore yaml) in favor of ruamel.yaml (ruamel dot yaml) with an upper bound.
您好~这里是罗壮的邮箱,我已收到您的来信,会尽快给您回复的,请稍作等待喔~