Reputation: 11
I am trying to compile my python code to a .exe file using pyinstaller. Using the following code yields a usable .exe file with no error messages:
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
window.show()
print('app loaded')
sys.exit(app.exec_())
However, as soon as I add:
from scipy.integrate import solve_ivp
to the import statements, I get the error message "Failed to execute script".
During execution of pyinstaller in the command window i also see the following: "WARNING: Unable to find Qt5 translations" plus several warnings including the Matplotlib module.
I tried copying the PyQt5\Qt\plugins\platforms
folder to the folder holding the .exe file and adding Anaconda3\Library\plugins as environment variable QT_PLUGIN_PATH
as suggested in another question, but both proposed solutions did not work.
When I try to execute the program from the command window I get the error message: "ImportError: DLL load failed"
Any help with this problem would be greatly appreciated.
Edit:
I tried oetzi's proposition and created a new anaconda environment specifically for my project. I installed the modules of scipy, numpy, matplotlib, and pyqt and installed pyinstaller in that new environment. This time I typed the commands in the Anaconda Prompt. Again, without scipy.integrate.solve_ivp it works fine. With it, I get the following error when i try to run pyinstaller.
18881 WARNING: Cannot read QLibraryInfo output: raised Expecting value: line 1 column 1 (char 0) when decoding:
False
Traceback (most recent call last):
File "C:\Users\domin\Anaconda3\envs\testenv\Scripts\pyinstaller-script.py", line 10, in <module>
sys.exit(run())
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\domin\polybox\ETH\Master Thesis\PycharmProjects\Perfusion Simulation\Pyinstaller\test\test.spec", line 17, in <module>
noarchive=False)
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
self.__postinit__()
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\build_main.py", line 502, in assemble
module_hook.post_graph()
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\compat.py", line 793, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\hooks\hook-PySide2.py", line 18, in <module>
collect_system_data_files(pyside2_library_info.location['PrefixPath'],
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 87, in __getattr__
return getattr(self, name)
File "C:\Users\domin\Anaconda3\envs\testenv\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 89, in __getattr__
raise AttributeError
AttributeError
Upvotes: 0
Views: 1667
Reputation: 11
Okay what I now did was to just completely uninstall and install everything again. Afterwards I only added the required modules which were scipy, numpy, matplotlib, pyqt5 and pyinstaller. After that, everything worked fine. My guess is, that since I had both, PyQt5 and PyQt4 installed, it messed with the modules. Now that I only installed PyQt5, everything is okay.
Upvotes: 0