woile / flashcards

small cli tool to study using flashcards
https://python-flashcards.readthedocs.io/
MIT License
13 stars 8 forks source link

module 'collections' has no attribute 'Hashable' #25

Open josepl08 opened 1 month ago

josepl08 commented 1 month ago

Hi!

I followed the installation as described in the documentation, copy pasted the example yaml content into an example.yaml file and I get the following error

$ flashcards example.yaml
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\JEPL\dev\swedish-flash-cards\venv\Scripts\flashcards.exe\__main__.py", line 7, in <module>
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\flashcards\cli.py", line 55, in main
    start(args)
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\flashcards\flashcards.py", line 204, in start
    parsed_file = yaml.load(stream)
                  ^^^^^^^^^^^^^^^^^
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\__init__.py", line 72, in load
    return loader.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\constructor.py", line 37, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\constructor.py", line 46, in construct_document
    for dummy in generator:
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\constructor.py", line 398, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\constructor.py", line 204, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\JEPL\dev\swedish-flash-cards\venv\Lib\site-packages\yaml\constructor.py", line 126, in construct_mapping
    if not isinstance(key, collections.Hashable):
                           ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Hashable'

These are the mosules I have installed future==0.16.0 python-flashcards==0.3.0 PyYAML==3.12

ment4list commented 1 week ago

I'm using this in a hurry and have the same issue.

I found a quick temporary solution. In site-packages/yaml/constructor.py simply comment out lines 126 to 128.

Doing that I can view the flashcards.