Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
yaml error in Pythonista 3.4
-
Hi,
I just updated to Pythonista 3.4 and wanted to use yaml for setting up a configuration file. I did this before on my DEV machine, so the following code (c&p) should work:
import yaml # Read yaml config with open('config.yaml', 'r') as file: configuration = yaml.safe_load(file)
However, in Pythonista I get an error, saying
AttributeError
module 'collections' has no attribute 'Hashable'It maybe has to do with the version of pyyaml running in Pythonista on Python 3.10 and is probably related to this issue:
https://github.com/yaml/pyyaml/issues/622Any way to fix it on my own? Or is a Pythonista update with a more recent yaml necessary?
Thanks in advance.
J. -
@johndoe77 said
It maybe has to do with the version of pyyaml running in Pythonista on Python 3.10
Yes, you're right...
-
@cvp put this code in the script where collections is imported
# Python 3.10 has put Hashable and MutableMapping in collections.abc instead of collections import collections collections.Hashable = collections.abc.Hashable collections.MutableMapping = collections.abc.MutableMapping
-
@cvp Thank you very much! As a workaround it does the job.
Hopefully, it's not a major hassle to upgrade Pythonista with a newer version of yaml.
-
@johndoe77 Solution does not come from me but from @ccc advice, see here
-
@omz please consider upgrading
pyyaml
in a future release.