Issue
I'm trying to create an executable file from my Python application with Pyinstaller, so I've created a virtual environment and I've installed all the required packages.
I have also installed snap7 wrapper with the command pip install python-snap7
.
If I run the python file from my terminal, it works fine. However, when I create the executable file with Pyinstaller and I try to run it, the following message appears and the application doesn't start:
Traceback (most recent call last):
File "myapp.py", line 772, in <module>
File "myapp.py", line 751, in main
File "snap7\client.py", line 64, in __init__
File "snap7\common.py", line 72, in load_library
File "snap7\common.py", line 63, in __init__
RuntimeError: can't find snap7 library. If installed, try running ldconfig
[22236] Failed to execute script 'myapp' due to unhandled exception!
Maybe I didn't install the complete snap7
library (as written in https://python-snap7.readthedocs.io/en/0.5/installation.html#snap7), but I don't know how to install it inside a Python virtual environment
Solution
I've found how to solve. When I run the .exe file, it searchs for the snap7.dll in the temp folder (_MEI) created by Pyinstaller and in the local path of the .exe file. So I've simply added the snap7.dll file to the local path where the .exe file is run, and it works
Answered By - nicc96 Answer Checked By - Robin (WPSolving Admin)