问题
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