Installing the package
I'm getting this error after trying all the following:
pip3 install pyyamlsudo python3 -m pip install pyyamlThe library in all cases seem to be properly installed.
$ pip3 show pyyaml
Name: PyYAML
Version: 5.4.1
Summary: YAML parser and emitter for Python
Home-page: https://pyyaml.org/
Author: Kirill Simonov
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.9/site-packages
In case of pipenv the location is
Location: /Users/<username>/.local/share/virtualenvs/webwatch-zMzxdqeP/lib/python3.8/site-packages
Usage
In the application I simply import pyyaml
and run it using either python3 <myapp>.py or doing the same thing using pipenv shell.
Result
On all cases ModuleNotFoundError: No module named 'pyyaml'
More info
$ ls -ls /usr/bin/python*
0 lrwxr-xr-x 1 root wheel 75 Jun 15 2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
0 lrwxr-xr-x 1 root wheel 82 Jun 15 2020 /usr/bin/python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
0 lrwxr-xr-x 1 root wheel 75 Jun 15 2020 /usr/bin/python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
0 lrwxr-xr-x 1 root wheel 75 Jun 15 2020 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
0 lrwxr-xr-x 1 root wheel 82 Jun 15 2020 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
16 -rwxr-xr-x 1 root wheel 31488 Aug 10 2020 /usr/bin/python3
0 lrwxr-xr-x 1 root wheel 76 Jun 15 2020 /usr/bin/pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
0 lrwxr-xr-x 1 root wheel 76 Jun 15 2020 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
References:
It's very simple and I'm surprised nobody has answered this yet: You just used the wrong name in the import statement.
The package is called PyYAML (see pip or the homepage), and so you indeed install it using:
pip install pyyaml
However, the Python package to import is called yaml.
So instead of:
import pyyaml
you should do:
import yaml
This can be seen in the examples in the tutorial.
Note that the three references you included in your question are about another error message, so they are not really relevant for this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With