Menu

#9 ImportError: cannot import name 'text_type' from 'ruamel.yaml.compat'

closed
pip (1)
minor
bug
2021-06-09
2021-06-08
Lucas Cimon
No

This tool, when installed with pip with Python 3.8, raises an ImportError when trying to invoke it:

$ pip install --user ruamel.yaml.cmd
Looking in links: file:///home/lucas_cimon/.pip-wheelhouse
Collecting ruamel.yaml.cmd
Downloading ruamel.yaml.cmd-0.5.6-py2.py3-none-any.whl (12 kB)
Collecting ruamel.std.argparse>=0.8
Downloading ruamel.std.argparse-0.8.3-py2.py3-none-any.whl (14 kB)
Collecting ruamel.yaml>=0.16.1
Using cached ruamel.yaml-0.17.7-py3-none-any.whl (108 kB)
Collecting ruamel.yaml.convert>=0.3
Downloading ruamel.yaml.convert-0.3.2-py2.py3-none-any.whl (9.9 kB)
Collecting configobj
Downloading configobj-5.0.6.tar.gz (33 kB)
Collecting ruamel.yaml.clib>=0.1.2
Using cached ruamel.yaml.clib-0.2.2-cp38-cp38-cygwin_3_2_0_x86_64.whl
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.8/site-packages (from ruamel.yaml.convert>=0.3->ruamel.yaml.cmd) (2.8.1)
Requirement already satisfied: six in /usr/local/lib/python3.8/site-packages (from configobj->ruamel.yaml.cmd) (1.15.0)
Using legacy 'setup.py install' for configobj, since package 'wheel' is not installed.
Installing collected packages: ruamel.yaml.clib, ruamel.yaml, ruamel.yaml.convert, ruamel.std.argparse, configobj, ruamel.yaml.cmd
Running setup.py install for configobj ... done
Successfully installed configobj-5.0.6 ruamel.std.argparse-0.8.3 ruamel.yaml-0.17.7 ruamel.yaml.clib-0.2.2 ruamel.yaml.cmd-0.5.6 ruamel.yaml.convert-0.3.2

$ yaml round-trip spec/target_files/ABT/nodes/nodesABT-PREP1.yaml
Traceback (most recent call last):
File "/home/lucas_cimon/.local/bin/yaml", line 8, in <module>
sys.exit(main())
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/main.py", line 215, in main
sys.exit(n.run())
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/main.py", line 51, in run
return self.args.func()
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/main.py", line 79, in rt
return self._yaml.round_trip()
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/yaml_cmd.py", line 497, in round_trip
e, w, stabilize, outp = self.round_trip_input(inp)
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/yaml_cmd.py", line 524, in round_trip_input
outp = self.round_trip_single(inp)
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/yaml_cmd.py", line 551, in round_trip_single
, mi2, si2, off2 = load_yaml_guess_indent2(inp, yaml)
File "/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/cmd/yaml_cmd.py", line 108, in load_yaml_guess_indent2
from ruamel.yaml.compat import text_type, binary_type
ImportError: cannot import name 'text_type' from 'ruamel.yaml.compat' (/home/lucas_cimon/.local/lib/python3.8/site-packages/ruamel/yaml/compat.py)</module>

Discussion

  • Anthon van der Neut

    • status: open --> closed
     
  • Anthon van der Neut

    This was a result of ruamel.yaml no longer supporting py27 and ruamel.yaml.cmd relying on some compatibility code in the former.
    I had already made all the necessary changes in ruamel.yaml.cmd (so it worked for me localy) but forgot to push a new version to pypi.
    There is 0.5.7 now on pypi which should have this fixed. Thanks for reporting

     
  • Lucas Cimon

    Lucas Cimon - 2021-06-09

    Thank you!

    I confirm that the latest ruamel.yaml.cmd-0.5.7 version works fine for me

     

Log in to post a comment.