Pyinstaller matlab-engine problem running the .exe on a different machine - python

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.

Related

No module named 'messagebox._win32' this platform is not supported: win32

I am trying to make an app using pyinstaller. Code is running fine and working, however, when I convert it into exe file it is throwing an error.
Traceback (most recent call last):
File "messagebox\__init__.py", line 45, in <module>
File "importlib\__init__.py", line 126, in import_module
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'messagebox._win32'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dummy.py", line 1288, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "messagebox\__init__.py", line 54, in <module>
ImportError: this platform is not supported: win32

I'm having an issue with PortAudio building app with py2app

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

One or more errors occurred while loading the module 'aspose.word'(-1009)

I'm trying to make an executable with pyinstaller but it's giving an error in a library I'm using called aspose.words
this is the error that appears to me:
if the image does not open:
Traceback (most recent call last):
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 655, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
KeyError: 'aspose.pydrawing'
The above exception was the direct cause of the following exception:
ImportError: Unable to import module dependencies. Cannot import the aspose.pydrawing module. The module not found or errors occurred while initializing it.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 3, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "Scripts\login.py", line 6, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "Scripts\principal.py", line 10, in <module>
File "aspose\__init__.py", line 48, in load_module
File "aspose\__init__.py", line 80, in _load_native_module
ImportError: One or more errors occurred while loading the module 'aspose.words' (-1009)
this is the command I used to create the executable:
pyinstaller --noconsole --onefile --collect-binar
ies "aspose" --collect-submodules "aspose" main.py --ico 3151580_game_maze_retro_icon.png
I saw a post here that needed to include aspose with the: --collect-binar command
ies "aspose" --collect-submodules "aspose". but the error continued
Try to use --collect-all option instead of --collect-binaries and --collect-submodules ones: such approach helped me.
i.e., try to use the following command:
pyinstaller --noconsole --onefile --collect-all "aspose" main.py --ico 3151580_game_maze_retro_icon.png

ttk bootstrap TypeError after compiling

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

I get an “wrong ELF class” error trying to import a python library that uses swig

I have been trying to import a python library called dwave tabu which uses swig, but I have been experiencing some issues. When importing the package in python3, I get this result:
>>>import tabu
Traceback (most recent call last):
File "/home/chip/.local/lib/python3.5/site- packages/tabu/tabu_search.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 914, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: /home/chip/.local/lib/python3.5/site-packages/tabu/_tabu_search.so: wrong ELF class: ELFCLASS64
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/chip/.local/lib/python3.5/site-packages/tabu/__init__.py", line 17, in <module>
from tabu.tabu_search import TabuSearch
File "/home/chip/.local/lib/python3.5/site- packages/tabu/tabu_search.py", line 17, in <module>
_tabu_search = swig_import_helper()
File "/home/chip/.local/lib/python3.5/site-packages/tabu/tabu_search.py", line 16, in swig_import_helper
return importlib.import_module('_tabu_search')
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_tabu_search'
I suspect that the error has something to do with swig, but I am unsure what to do to resolve it. Also It looks like is an error about may be caused by binary compiled for 64-bit linux, on a 32-bit installation, but I don’t know how to fix that issue. Any help would be greatly appreciated.
Thanks
ImportError: /home/chip/.local/lib/python3.5/site-packages/tabu/_tabu_search.so: wrong ELF class: ELFCLASS64
This error means: you are trying to load a 64-bit _tabu_search.so library into a 32-bit process. You must either use 64-bit python, or install a 32-bit version of the tabu_search package.
I suspect that the error has something to do with swig
No, SWIG has almost nothing to do with your problem.

Categories

Resources