-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use pyinstaller to pack into exe file and get no device. #36
Comments
Hi @pineappleliubo, could you try the current master? I believe this issue was fixed in c34e798 |
Hi @pineappleliubo and @stefanklug, |
Supplementary pyinstaller package process information; A warning message is displayed in the packaging process, and the final package is successful. The EXE program cannot execute the camera device.D:\workspace\brose\first_camera\CMQI>pyinstaller -F CMQI.py D:\workspace\brose\first_camera\CMQI> |
Hi @pineappleliubo, |
@RoccoMatano |
Apparently
You probably need some other files if you're not using a USB3 vision camera.
|
I think @fncnt pointed in the right direction. But i would solve it this way:
|
I am having this same problem. I've tried the solutions suggested by @fncnt and @RoccoMatano , but when running the executable generated by pyinstaller, no camera is ever found. The same code works fine when run with Python and finds my camera. Details: I've modified the .spec file to include ALL the files in the Runtime/x64 folder. The program file I'm using is this (filename is enum_cameras.py):
When I run the executable, I get this output: Is there a way to get more detailed debugging information? UPDATE: Problem was me... the solution given by @RoccoMatano does indeed work -- I had a typo in my .spec file. Fixed it, and now it's all hunky-dory! |
I have encountered the same problem, what should I do according to your method?@RoccoMatano |
Here's the .spec file I used - maybe this will help. You have pass the .spec file to pyinstaller instead of the .py file, so in this case I use "pyinstaller example.spec"
|
I am not familiar enough with pyinstaller, and I am too careless. Now it works.thank you very much |
@RoccoMatano Thank you very much. I encountered the same problem, and directly solve it with your method. You saved me much time. Thanks again! |
Just wanted to add that if you are "compiling" a python script on Linux, @RoccoMatano's answer above works with one small modification:
must be changed to:
as Linux uses .so files instead of .dll files for shared libraries. |
Just hit this problem as well. I tried fixing the problem by creating # hook-pypylon.py
from PyInstaller.utils.hooks import collect_dynamic_libs
binaries = [
(lib, ".") for lib, path in
collect_dynamic_libs("pypylon")
] |
I'm not sure if this is due to a specific change in # hook-pypylon.py (requires python 3.8)
import importlib.metadata
pypylon_dist = importlib.metadata.distribution("pypylon")
base_path = pypylon_dist.locate_file(".")
dynamic_libs = [
(base_path / f) for f in pypylon_dist.files
if f.suffix.lower() in (".so", ".dll", ".dylib")
]
binaries = [(lib, ".") for lib in dynamic_libs] |
Get the transport layer factory.
tlFactory = pylon.TlFactory.GetInstance()
Get all attached devices and exit application if no device is found.
devices = tlFactory.EnumerateDevices()
if len(devices) == 0:
raise pylon.RuntimeException("No camera present.")
The above code runs normally.
But when pyinstaller is packaged into exe, the exception "RuntimeException No camera present." is thrown.
The text was updated successfully, but these errors were encountered: