ModuleNotFoundError: No module named 'yaml'
10,507
You have not provided quite enough information for an exact answer, but, for missing python modules, simply run
py -m pip install PyYaml
or, in some cases
python pip install PyYaml
You may have imported it in your project (on PyCharm) but you have to make sure it is installed and imported outside of the IDE, and on your system, where the python interpreter runs it
Author by
iamj
Updated on December 05, 2022Comments
-
iamj over 1 year
I have used a YAML file and have imported PyYAML into my project.
The code works fine in PyCharm, however on creation of an egg and running the egg gives an error as module not found on command prompt.
-
Anthon almost 6 yearsOn which platform can you start Python by just using
py
? The "some cases" you refer to can only occur on a platform where thepip
command has no extension (like.bat
), yourpython
is in your path and you are in thebin
directory of your installation (sopip
) can be found. In that case you should be able to do justpip install pyyaml
, unless pip is incorrectly installed. -
ntrupin almost 6 yearsI have python on my Windows 10 laptop, and, after much worry that it was configured poorly, I found out that all of my commands had to start with py -something, with -m being the extension for installing modules
-
iamj almost 6 yearsThanks @Anthon, I shall try this out. However, as ntrupin mentioned, i was able to resolve it once i tried installing pyyaml in my machine. I was of the assumption that since the Setup.py had PyYaml as a dependency, it would automatically install it.
-
Anthon almost 6 yearsIt should install automatically if you include the above in your
setup.py
. If you have to do so by hand for each virtualenv you create you are bound to forget it. (And I hope you are not clobbering the system wide python with your programs and packages.) -
A.P. over 3 yearsIn my case (Windows 10 desktop) I had to run "python -m pip install PyYaml".
-
Ryan Kyle over 2 yearsOn MacOS with python version 3.9.7 and pip version 21.2.4, I had to run
pip3 install PyYAML
.