ModuleNotFoundError: No module named 'yaml'

不想你离开。 提交于 2020-05-16 02:02:19

问题


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.


回答1:


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




回答2:


I have not made an .egg for some time (you really should be consider using wheels for distributing packages), but IIRC an .egg should have a requires.txt file with an entry that specifies dependency on pyyaml.

You normally get that when setup() in your setup.py has an argument install_requires:

setup(
...
install_requires=['pyyaml<4']
...
)

(PyYAML 4.1 was retracted because there were problems with that version, but it might be in your local cache of PyPI as it was in my case, hence the <4, which restricts installation to the latest 3.x release)



来源:https://stackoverflow.com/questions/51333654/modulenotfounderror-no-module-named-yaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!