I am using Python 3.3.3 and I have been trying to build a .exe from a simple .py script.
My script looks like this:
import encodings
print('Test')
and executes correctly.
When I try to build it with PyInstaller with this command:
pyinstaller --onefile Testmodul.py
and try to open my .exe it shows up with this error:
Fatal Python error: Py_Initialize: unable to load the file system codec, ImportError: No module named 'encodings'
I already tried importing the 'encodings' module in my testscript but it is still not working, I have also tried py2exe and it is also not working at all.
Is there anything I do wrong? Do I have to setup something in my PATH? the correct path to "C:\Python33" is included in there already.
EDIT: To everyone with this problem: I gave up, and after a fresh install of windows and python and all the other stuff, I tried it again, the same way as before and it worked without a problem.. It is worth a try if you are really desperate!
This is probably because pyinstaller did not include the module in the first place. Try one of the following solutions.
1) Specify the path to your module during compilation:
2) Specify the path from the .spec file:
run this command first(in pyinstaller's directory):
python Makespec.py --onefile /path/to/yourscript.py
now you have the .spec file. open it in your text editor, and add the path to your modules to the pathex.
pathex=['C:\\path\\to\\module']
then, build your program:
python Build.py /path/to/yourscript.spec
3) Use hidden imports:
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