The following error occurs after I have compiled my program and try to run the .exe:
pygame 2.1.2 (SDL 2.0.18, Python 3.10.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "main.py", line 35, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "GUI.py", line 74, in <module>
TypeError: Style.__new__() got an unexpected keyword argument 'themes_file'
[4196] Failed to execute script 'main' due to unhandled exception!
I have tested it on 3 PCs. The results are, that as long as I run my code from VS Code, it works. It also works compiled to .exe for one friend using windows 10.
It does not work on my Windows 11 PC and also not on my second Laptop which is running Windows 10 also.
There was never any issue like that before and I can't understand whats going on
Related
I am building an python project with Eel, and I'm trying to package my program to an exe with PyInstaller as instructed in the documentation. However, I get the following error when I open the .exe:
Error
Traceback (most recent call last):
File "hello.py", line 1, in <module>
import eel
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "eel\__init__.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "bottle.py", line 73, in <module>
AttributeError: 'NoneType' object has no attribute 'write'
I tried to use auto py-to-exe instead of Pyinstaller, but I got the same error. Finally, I tried to package the Eello world example from the Eel documentation to see if it was my program that was the issue, but I still got the same error. I found a similiar problem in a github issue, but I fail to see what I should attach to --add-data.
I am running Python 3.10.8 and Eel 0.14.0. I've now tried python 3.8.9 and python 3.9.13 without luck.
Update
Upon further investigation, I discovered that the error only occours when I attach --noconsole at the end of my cmd python -m eel hello.py web --onefile --noconsole . However, I want my app to work without a visible console.
One of the libraries you are using is attempting to write to sys.stdout and sys.stderr, which are set to None when you run pyinstaller with --windowed option.
You need to explicitly set sys.stderr and sys.stdout in your programs code as early as possible to a writeable object like an open file or an io buffer.
for example:
import sys
outfile = open("logfile.txt", "wt")
sys.stderr = outfile
sys.stdout = outfile
enter code hereI have to update an app I made on an Intel MacBook Pro to an Apple Silicon MacBook Pro. I am having problems after build the app file with py2app. I do not know if it also has to do with MacOS Ventura. I am using python 3.9 and have installed PortAudio with Homebrew
It works perfectly if I run it directly from Terminal but if I run the app I get this lines debugging
/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
myuser#MacBook-Pro-myuser ~ % /Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
Traceback (most recent call last):
File "sounddevice.pyc", line 71, in <module>
OSError: PortAudio library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 170, in <module>
_run()
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 84, in _run
exec(compile(source, path, "exec"), globals(), globals())
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/JFSTOOLS.py", line 27, in <module>
import sounddevice as sd
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "sounddevice.pyc", line 83, in <module>
OSError: cannot load library '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib': dlopen(/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib, 0x0002): tried: '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20), '/System/Volumes/Preboot/Cryptexes/OS/Users/jose/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (no such file), '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20)
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
See the py2app website for debugging launch issues
I have tried to update sounddevice, numpy, portaudio, etc but I am lost as I am not an expert. Any help would be appreciated
I'm working on an application that uses the matlab engine API for python.
The app works fine, without any issue, therefore I wanted to pack it into a single exe.
At first I had an issue given by mlarray, that I solved by compiling with:
pyinstaller --additional-hook-dir=hooks --onefile main.py
Now on my own computer the .exe file works fine, but as soon as I try to run it on a different machine (with Matlab installed), it gives me the following error:
Traceback (most recent call last):
File "matlab\engine\__init__.py", line 45, in <module>
File "importlib\__init__.py", line 127, in import_module
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matlabengineforpython3_8'
During handling of the above exception, another exception occurred:
'Traceback (most recent call last):
File "matlab\engine\__init__.py", line 67, in <module>
File "os.py", line 1109, in add_dll_directory
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'F:\\Matlab\\extern\\engines\\python\\..\\..\\..\\bin\\win64'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "matlab\engine\__init__.py", line 70, in <module>
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: [WinError 3] The system cannot find the path specified: 'F:\\Matlab\\extern\\engines\\python\\..\\..\\..\\bin\\win64'
[10656] Failed to execute script 'main' due to unhandled exception!
It seems that it can't find the module "matlabengineforpython3_8", which in theory is in the engine folder in the matlab installation path.
Then it's looking for a file in the wrong place, because the machine doesn't have an F: disk, but my computer does.
Some Context: I am currently working on a project to communicate between a PyParrot Mambo drone and the Leap Motion Controller. The issue that I am having is that the Leap Motion Controller Software only works in python 2.7 and the PyParrot Mambo Drone is working in Python 3.9. I was able to find a binding for the Leap Motion Controller Software to work with Python 3.7 .When I try to run the Leap Motion code that works in Python 3.7 in Python 3.9 I get an error.
Here is the binding file used to run The Leap Motion Controller in Python 3.7. I get the following error when I run the Sample.py file from the provided folder in python 3.9:
(py39) C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7>python Sample.py
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 565, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1108, in create_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Sample.py", line 9, in <module>
import Leap, sys, time
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 17, in <module>
LeapPython = swig_import_helper()
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 16, in swig_import_helper
return importlib.import_module('LeapPython')
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
If someone could provide clarifications on what changes were made between python 3.7 to 3.9 that would cause these errors and a possible fix to make the python 3.7 code compatible with python 3.9. If There is a Leap Motion Software binding for newer versions of python 3 that would also be quite helpful.
The binding was generated with SWIG which does not implement the Python Stable API so you will need to rebuild the binding for each Python Version for this to work with Python 3.9.
This guide was written for Python 3.3.0 but should help to guide you on the process to rebuild this for Python 3.9.
I have freshly installed windows 10 and I am trying to run the following code.
import pyttsx3;
engine = pyttsx3.init();
engine.say("I will speak this text");
engine.runAndWait() ;
This use to work on my previous windows 10 installation but now it is giving me following error
Traceback (most recent call last):
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ayush/Desktop/sample.py", line 2, in <module>
engine = pyttsx3.init();
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
import win32com.client
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am using python 3.6.6 64 bit on windows 10.
I have spent many hours trying different solutions like reinstalling python, tried python versions 3.5 and 3.7, reinstalling pyttsx3, also tried solutions given in few related questions but nothing is working.
Thanks in advance
Seems like win32api.pyd (which really is DLL) is not a win32 application. So I think it's loading 64bit drivers to 32bit runtime.
In this case, I will try to uninstall 64bit python, delete it's folder and install a 32bit version. I believe this will solve your problem, since you don't really need 64bit python.
Now the problem is in win32*.pyds, so it seems like your pyttsx3 is 32bit.
According to pypi.org, you can try pip install pypiwin32 to fix both win32 and win32api errors.
I tried installing Python 32 bits but customized with all options available such as a complete library, doing this worked wonders in breaking the errors! Just lauch the .exe launcher again, hit Modify and then just install every option!