ModuleNotFoundError: py3k for PyInstaller + savReaderWriter - python

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.

Related

How can I solve "No module named 'pyi_splash'" after using pyinstaller?

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

Pack pytest with pytest_html module using pyinstaller

I am having an issue to pack pytest with pytest_html module to an executable using pyinstaller
On Windows.
When running it with Python it does work, but I need to pack it as exe.
My example code:
import pytest
import pytest_html
def test_hello():
assert True
pytest.main(["-p", "pytest_html","-vvv", "--capture=tee-sys","--html=report.html", __file__])
Also Tied with
pytest.main(["-vvv","--html=report.html", __file__], plugins=[pytest_timeout])
The Pyinstaller command I am running is:
pyinstaller --noconfirm --onefile --nowindow --exclude-module PyQt5 --log-level DEBUG -n py_exe file.py
Also tried adding it as a hidden module with no luck.
The result I am getting is:
error: unrecognized arguments: --html=report.html
Looking at Analysis-00.toc, I can see the module :
('pytest_html', 'c:\\users\\nathan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pytest_html\\__init__.py', 'PYMODULE')
Versions: Windows 10,
Python 3.8.3,
pytest 5.4.3,
pytest-html 2.1.1,
pyinstaller 3.6
EDIT:
Issue was fixed, see https://github.com/pyinstaller/pyinstaller/issues/5016

Make executable a PyQt5 project

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

pywintypes.error - Using pyinstaller to create a one-file bundled executable

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

Error when creating executable file with pyinstaller

I'm trying to create an exe for my python script using pyinstaller each time it runs into errors which can be found in a pastebin here.
Also when I double click the exe file it shows this error:
C:Users\Afro\AppData\Local\Temp_MEI51322\VCRUNTIME140.dll is either not designed to run on windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc000007b
and then this:
Error loading Python DLL:
C:\Users\Afro\AppData\Local\Temp_MEI51322\python35.dll(error code 193)
what's wrong, please?
I was haunted with similar issue. It might be that in your case UPX is breaking vcruntime140.dll.
Solution to this is turning off UPX, so just add --noupx to your pyinstaller call.
pyinstaller --noupx --onedir --onefile --windowed get.py
Long explanation here: UPX breaking vcruntime140.dll (64bit)
I have also met this issue, and the root cause is that I am using upx to compress the file size. The solution is to exclude files which should not be compressed by upx:
pyinstaller --onefile --console --upx-dir=/path/to/upx --upx-exclude=vcruntime140.dll --upx-exclude=python36.dll my_script.py
In my case it was:
pyinstaller --clean --win-private-assemblies --noupx --onedir --onefile script.py
--windowed caused problems with wxWidgets
I tried with this version of Pyinstaller commands, Add this commands to a .bat file and execute the .bat file. It worked for me:
pyinstaller --log-level=WARN ^
--upx-dir <PATH_TO_UPX.exe_FILE> ^
--upx-exclude vcruntime140.dll ^
--upx-exclude ucrtbase.dll ^
--upx-exclude qwindows.dll ^
--upx-exclude libegl.dll ^
--name <NAME_OF_APPLICATION> ^
--onefile --windowed ^
<PY_DEPENDENT_FILES.py>

Categories