I'm trying to add a splashscreen to my app using pyinstaller by this:
pyinstaller.exe --onefile --splash=Splash_screen.png --icon=Icon.ico JIGOverview.pyw
this opens the splashscreen but it never closes so then I try to add this code to my Python code:
import pyi_splash
pyi_splash.update_text('UI Loaded ...')
pyi_splash.close()
but I get a "No module named 'pyi_splash'" error. How do I add this module to my code?
Add the --hidden-import option:
pyinstaller.exe --onefile --splash=Splash_screen.png --icon=Icon.ico --hidden-import=pyi_splash JIGOverview.pyw
Related
I have created a Python script, which uses customtkinter for a GUI where the user can select some options.
Here is an overview about the imported packages:
used libraries
Everything works properly when I run the script in Pycharm (Community Edition 2021.1.2) and the GUI shows up as expected.
But after building (creating an exe from the script) using pyinstaller and running the exe I get following error message:
Error when running exe file
Line 403 makes a problem acc. to this message - the corresponding line in the script looks like:
Line 403 causes error
For building the exe I use following command:
pyinstaller --noconfirm --onedir --windowed --add-data c:\users\myName\appdata\local\programs\python\python39\lib\site-packages\customtkinter;customtkinter\ DataAnalysisTool.py
Hope somebody can help!
I would expect that the exe file also runs as the script in Pycharm runs without any problem.
Update: minimum reproducible example (throws same error message when running exe)
import customtkinter
# create the root window
root_file = customtkinter.CTk()
root_file.title('Data Analysis Tool - File Selection')
root_file.resizable(False, False)
root_file.geometry('350x150')
root_file.mainloop()
I was able to compile your example code with the following steps:
Create a new virtual environment and install customtkinter and pyinstaller
create a main.py file with your example code.
import customtkinter
# create the root window
root_file = customtkinter.CTk()
root_file.title('Data Analysis Tool - File Selection')
root_file.resizable(False, False)
root_file.geometry('350x150')
root_file.mainloop()
run pyinstaller -F main.py --collect-all customtkinter
The compiled executable runs without error.
It works using the --onedir option as well.
I've tried to make a PyQt5 project an executable file.
I used a PyInstaller module, and I got a half success.
pyinstaller --clean -w -F --specpath=spec -n=project_name -i="..\resource\logo.ico" src\main.py
The executable file generated by this command did not run successfully.
The error message was like this.
pyinstaller --clean -c -F --specpath=spec -n=project_name -i="..\resource\logo.ico" src\main.py
The executable file generated by this command ran successfully.
But it has a terminal even though it is a GUI project.
The difference is just -c and -w. But one can be executed and can not one.
How should I do it?
The problem was subprocess.Popen with Python v3.7.5.
I didn't set the stdin. I set only stdout, stderr.
After I set the stdin=subprocess.PIPE, it works well.
And I want to add 1 more thing.
I've imported the win32api module with Python v3.8.0. This raises issues.
So, I've added the module pywintypes, and now the issue is resolved.
Before
import win32api
After
import pywintypes
import win32api
I want to use PyInstaller with module savReaderWriter. My code is very simple:
import savReaderWriter
print("hello world")
input("Press enter, to finish...")
I was trying to use hidden import with appropriate module:
pyinstaller --clean --win-private-assemblies --upx-exclude=vcruntime140.dll --onedir --hidden-import="savReaderWriter" temp.py
pyinstaller --clean --win-private-assemblies --upx-exclude=vcruntime140.dll --onedir --hidden-import="py3k" temp.py
pyinstaller --clean --win-private-assemblies --upx-exclude=vcruntime140.dll --onedir --hidden-import="py3k" --hidden-import="savReaderWriter" temp.py
But in all cases I have received the same error:
ModuleNotFoundError: No module named 'py3k'
I solved the issue by including the path of the savReaderWriter to the parameter.
pyinstaller -p "C:\PyProjects\test\venv\Lib\site-packages\savReaderWriter"; test.py
Also, the real pain is when you trying to delete the module, an Error will occur because it is finding a non "UTF-8" character.
I wrote a tool with an interface with PyQt5+Python3.6, and I want to pack into an .exe file to run on a machine without a Python environment. According to the online use of pyinstaller to pack, after the end of the package in the dist folder exe file is opened after the error:
ModuleNotFoundError: No module named 'scipy._lib.messagestream'
This issue was revised after the hiddenimports of the .spec file was resolved:
hiddenimports=['scipy._lib.messagestream']
and then the new .exe file generated by the command:
pyinstaller x.spec
still reports an error.
ModuleNotFoundError: No module named 'typedefs'
Then, continue to add ... continue to error, all this error...
How do you solve this problem?
Are you working in a virtual environment (venv)?
If so, you should add the site-packages path:
pyinstaller --paths path\to\venv\Lib\site-packages script.py
It happens to me with selenium module until I run pyinstaller with the --paths
Running Powershell in the same directory as:
pyinstaller --onefile --icon=<my_Logo.ico> BC-USD.py
It always end up with the same error:
pywintypes.error: (2, 'LoadLibraryEx', 'The system cannot find the file specified.')
How can I fix this?
Does your code import a dll? If so, you need to tell pyinstaller to include it using the --add-binary or --add-data option:
pyinstaller --onefile --icon="icon.ico" --add-binary "current/path/to/dll/my_dll.dll; folder/to/store/dll/inside/pyinstaller/bundle"
http://pyinstaller.readthedocs.io/en/stable/usage.html