Greenjoy
Greenjoy

Reputation: 79

Python script compiled to .exe giving error: No module named yaml

I can run the code below in Pycharm without issues, but when I create an exe using pyinstaller, I get the following error when I run the executable -

**Traceback (most recent call last):
  File "openfile.py", line 1, in <module>
ImportError: No module named yaml
[1296] Failed to execute script openfile**
import yaml
from sys import exit

cfg = yaml.safe_load(open("Config.yml"))

exit()

Note that I'm using Windows 10.

Upvotes: 0

Views: 1281

Answers (1)

Mohit Chandel
Mohit Chandel

Reputation: 1916

pip install pyyaml will solve this problem

or use virtualenv

pip install virtualenv -p python3 #or python2
virtualenv venv
venv/Scripts/activate
pip install pyyaml

Upvotes: 3

Related Questions