Error message using pyinstaller - python

I am trying to convert a script into an exe using pyinstaller and Python3.70 (on Windows 10)
When I run the command
pyinstaller --onefile myfile.py
The program runs fine, except some warnings about libcrypto etc..
But when I try to run the exe file found in the dist folder I get this error message:
Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x00002afc (most recent call first):

Try down-grading to Python 3.6, it seems there are issues with Pyinstaller and Python 3.7 that have not yet been addressed. As per Pyinstaller:
PyInstaller works with Python 2.7 and 3.3—3.6

Related

Crypto Module not Found for pyinstaller

I want to turn my Python script into a single executable with all the dependencies in place. For this purpose I am using pyinstaller. I have installed it globally on my machine and set up a virtualenv for my project. While the virtualenv is active I am executing the following command:
pyinstaller --onefile --paths /path/to/venv/lib/python3.9/site-packages script.py
This creates an executable but when I try to run it it gives me:
ModuleNotFoundError: No module named 'Crypto.Util.Padding'
In the warning file it gives me the following line:
missing module named 'Crypto.Util.Padding' - imported by sp_api.base.helpers (top-level)
And during executable generation the output includes:
6427 INFO: Loading module hook 'hook-Crypto.py' from '/home/user/.local/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'Crypto.Math'
When executing the command
pyinstaller --onefile myscript.py
under windows, it works perfectly fine even without specifying the venv path. When performing the same step in linux, the executable fails with the first non-standard import (flask in this case).
After also adding the path for lib64 from the corresponding venv the Crypto library is found.
pyinstaller --onefile --paths /path/to/venv/lib/python3.9/site-packages \
--paths /path/to/venv/lib64/python3.9/site-packagesscript.py

Linux - Pyinstaller Error "failed to execute script " - Convert Python to ELF executable

I'm trying to make a linux executable from my python program with: pyinstaller --onefile tool.py, it doesn't work, I get an executable in the ./dist folder, I try to run it and I have the error "Failed to execute script {name}"
The program works fine with python 3 but the executable fail to run
Output of the executable ./dist/tool
ModuleNotFoundError: No module named 'Cryptodome'
[5912] Failed to execute script tool
the module Cryptodome is already installed but still Getting No module named Cryptodome in pyinstaller

How can I avoid Pyinstaller import win32clipboard error?

I use PyInstaller (Win 10) to create a text analyzing app. But though it works fine in Visual Studio Code, the exe file creates an error.
I use:
pyinstaller --onefile textanalyzer_02.py
But starting the exe file gives me the following error:
Traceback (most recent call last):
File "textanalyzer_02.py", line 2, in <module>
import win32clipboard
ImportError: DLL load failed while importing win32clipboard: Das angegebene Modul wurde nicht gefunden.
[7604] Failed to execute script textanalyzer_02
I tried also:
pyinstaller --onefile textanalyzer_02.py --hidden-import win32clipboard
But it didn't work either. Any ideas?
Came across this while having the same issue. Found a solution that worked for me. I imported pywintypes into my script before win32clipboard:
import pywintypes
import win32clipboard
After that, my compiled program ran again without any errors. Windows 10 / Python 3.8.6 / PyInstaller 4.0.
This worked for me . I found the two dll files in my python installation folder and simply copied them to \windows\system32
pywintypes39.dll
win32clipboard39.dll
Your file names vill vary with the version of python you have.

Python exe runtime error: Fatal Python error: Py_Initialize: Unable to get the locale

I'm running Anaconda 64-bit, with Python 3.5.5, on Linux Mint Xfce 18.3, 64-bit. I want to use PyInstaller to create an executable. After struggling through the PyInstaller install (not trivial), I ran pyinstaller test_build.py, where test_built.py consists solely of
print("Hello, world!")
I don't get any warnings or errors that are unexpected (overwrites folder if I've done it before, of course). I cd into ./dist/test_build and run ./test_build, and I get the following errors:
Fatal Python error: Py_Initialize: Unable to get the locale encoding
zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x00007fe95dc36700 (most recent call first):
Aborted (core dumped)
Any ideas? Thanks so much for your time!

Unable to load the file system codec

Here is the code i try to compile into .exe
from tkinter import *
fenetre = Tk()
label = Label(fenetre, text="Hello World")
label.pack()
fenetre.mainloop()
I open the cmd and type
pyinstaller test.py
Everything goes well, "22826 INFO: Building COLLECT out00-COLLECT.toc completed successfully."
But when i launch my application i got this error message :
Fatal Python error : initfsencoding: unable to load the file system
codec zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x00001954 (most recent call first):
I searched everywhere for like 2 hours nothing work...
I tried cx_Freezer too
Do you have any idea how to fix it ?
Thanks !
I used to have same problem using
pyinstaller --onefile my_file.py
I was using Python 3.7, After switching to 3.6 it works just fine!
So its probably that 3.7 isn't supported yet by PyInstaller

Categories

Resources