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
Related
In my python script, I use the requests module to call an API to GET and POST data.
Python environment: anaconda3, python 3.7 / packages: requests 2.24.0, pyinstaller 3.6, openssl 1.1.1h...
I have the following problem with the EXE-file generated by PyInstaller: When I run this file, I get the following error message. This error doesn't occur when I run my script from Python:
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\rthooks\pyi_rth_certifi.py", line 13, in <module>
File "c:\programdata\anaconda3\envs\...\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "ssl.py", line 98, in <module>
ImportError: DLL load failed: The specified module could not be found.
[20188] Failed to execute script pyi_rth_certifi
If I follow to the excepted error lines (ssl.py):
import _ssl # if we can't import it, let the error propagate
Why can't ssl be imported?
I searched a long time in serveral post on SO but all these answers didn't help, ex.:
Python Requests throwing SSLError
Python Requests - How to use system ca-certificates (debian/ubuntu)?
Twilio Python Module Errors After Compiling
Fixing SSL certificate error in exe compiled with py2exe (or PyInstaller)
Does anyone have an idea how to fix this?
If you need more informations, please write a comment. THX
EDIT: (for Mooncrater's comment)
added Screenshot from python console, entered:
import _ssl
EDIT 2:
Tested "FIX" from SO Question:
Python SSL Import Error in PyInstaller generated executable
-> this didn't fix my problem
EDIT 3: Answer by cbolwerk
THX for your answer, this works!
Python 3.7 anaconda environment - import _ssl DLL load fail error
An additional fix is to install the latest OpenSSL Lib, I used 1.1.1h package in my python script, on my PC was installed an older version and that causes the error too.
cbolwerk's answer I tested on a PC where NO OpenSSL is installed and , as I wrote, it works!
If you can import ssl in the python within your environment, it means that the ssl module is probably inside your environment. This answer mentions the files you can look for inside your environment. They are either inside your env/Library/bin or env/DLLs. I think you have these installed, but pyinstaller doesn't recognize them. To make sure that pyinstaller knows these files, you can add them to datas. This can be edited in the command when building the .exe file or in the .spec file that is probably created when you have run this command once. This link may be useful there.
In short, add the paths of the DLLs I mentioned to the datas (or binaries inside .spec actually) so that they are recognized by pyinstaller.
So either run the command
pyinstaller --onedir --add-data libcrypto-1_1-x64.dll;. --add-data libssl-1_1-x64.dll;. myscript.py
or change your .spec to something like
datas = [('/path/to/libcrypto-1_1-x64.dll', '.'), ('/path/to/libssl-1_1-x64.dll', '.'),
(...) ]
...
a = Analysis(...,
datas=datas,
...)
...
and then run
pyinstaller --onedir myscript.spec
This fixed DLL issues for me at least.
So i'm packaging a python script with pyinstaller, and when I run the executable that is output in the dist folder, i see this error:
https://gyazo.com/729db46f4e7973b475b11c5a9810da19
Here is a screenshot of the error since the video goes fast:
https://gyazo.com/6f39ffd35561c3bc976aa9e52ee363f4
The line that the error refers to is this:
title = pyfiglet.figlet_format("Discord Tools")
How do I fix this?
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!
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
I have this script which read bar codes from images.
from PIL import Image
import zbar
scanner = zbar.ImageScanner()
scanner.parse_config('enable')
pil = Image.open('zbartest2.png').convert('L')
width, height = pil.size
raw = pil.tostring()
image = zbar.Image(width, height, 'Y800', raw)
scanner.scan(image)
for symbol in image:
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data
del(image)
When i put this script in python main directory which is C:\Python27 it works without any problem.
However, when i put this script outside of main directory such as C:\myscript, it gives me error saying that import zbar - module The specified module could not be found.
What is causing the problem?
I am using Python 2.7 32bits on windows Xp 32bits SP3
EDIT:
I am executing it from the IDLE window by using run module command (F5)
;full traceback
Traceback (most recent call last):
File "C:\myscript\test.py", line 2, in <module>
import zbar
ImportError: DLL load failed: The specified module could not be found.
when i type in import zbar; print zbar.__file__
i get the following msg
C:\Python27\lib\site-packages\zbar.pyd
It seems the dll is in c:\Python27 but c:\Python27 is not in the search path. Try the adding
import sys
sys.path.append("C:\Python2.7")
to your code before importing zbar.
If works correctly, then you have to configure your python's search paths in order to add C:\Python27. I work on linux, sorry I can't help you to do that on Windows.
EDIT: Well, I don't like write in an answer that I don't know how to do something. So I do some research looking for some doc that help me figure out what your problem is. And found it here importing PYD files.
Make sure you have all the files that you are importing in the same directory as this script