- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I had installed the OpenVINO through pip. These are my current OpenVINO versions:
openvino 2022.1.0
openvino-dev 2022.1.0
Importing OpenVINO and the execution of the complete code is good when I am running it as a python script. When I try to build the executable, I am getting issues with DLLs. Then I write a piece of code separately, which will import OpenVINO and print the available_devices.
Please find the code below:
from openvino.inference_engine import IECore
ie = IECore()
print("Devices:", ie.available_devices)
Output when ran as python script : Devices: ['CPU', 'GPU']
Pyinstaller command: pyinstaller test.py --onefile
When I run the executable, I am getting the following error.
D:\XXXX\dist>test.exe
Traceback (most recent call last):
File "test.py", line 1, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "openvino\inference_engine\__init__.py", line 30, in <module>
ImportError: DLL load failed: The specified module could not be found.
[8456] Failed to execute script 'test' due to unhandled exception!
I tried searching for the solution, but I am unable to find the exact one. It will be great if this issue can be resolved.
Thanks and Regards
Anjaneya Srujit,
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjaneya Srujit,
Thank you for reaching out to us.
For your information, PyInstaller is not officially supported by OpenVINO™. However, I did manage to create a working executable file using PyInstaller with the following command:
pyinstaller --onefile --add-data "C:\Program Files (x86)\Intel\openvino_2022.1.0.643\python\python3.7;." --hidden-import pkgutil --hidden-import numpy test\test.py
I've also replicated your issue and received similar error message as yours when executing the test.exe file without initializing the OpenVINO™ environment:
To avoid this error, you will need to setup the OpenVINO™ environment by running the setupvars.bat file before executing the test.exe file.
Here is the result for executing the test.exe file after running setupvars.bat file:
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hairul,
Thank you for the response.
Currently, I had installed OpenVINO with pip. The "setupvars.bat" file will be available when I install the OpenVINO using an installer. So this will not be possible in my case.
Is there any way to build the executable with OpenVINO(pip) support?
Thanks and Regards,
Anjaneya Srujit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjaneya Srujit,
I've successfully built the executable file using PyInstaller following these steps:
1. Installed PIP OpenVINO development package in a virtual environment as described in this guide.
2. Installed PyInstaller development version inside of the OpenVINO virtual environment:
python -m pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
3. Run the following command to build the executable file using PyInstaller:
pyinstaller --onefile --add-binary "C:\<openvino_env_dir>\Lib\site-packages\openvino\libs;." --hidden-import pkgutil --hidden-import numpy --hidden-import openvino.inference_engine.constants test.py
Here is the result for running the executable file:
Please ensure that you are running the PyInstaller command while inside of your OpenVINO virtual environment in order to avoid ImportError or ModuleNotFoundError.
You can refer to this StackOverflow discussion regarding importing modules for PyInstaller executables.
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hairul,
Thank you for the response.
Previously, my python version is 3.6.9. With python 3.6.9, the above-mentioned steps are not possible as the mentioned pyinstaller requires python>3.7. So I installed python 3.8.0 for the process.
I have followed the steps that you mentioned with python 3.8. I didn't face any issues related to pyinstaller. Now I am not getting any type of errors related to DLL's, but I am unable to see the print statement, that is present in the script.
When I ran the script as a python file, it is working well.
test.py file:
from openvino.inference_engine import IECore
ie = IECore()
print("Devices:", ie.available_devices)
Output:
(openvino_env) D:\srujit_exp>python test.py
Devices: ['CPU', 'GPU']
Now I generated the executable with the command mentioned.
pyinstaller --onefile --add-binary "D:\srujit_exp\openvino_env\Lib\site-packages\openvino\libs;." --hidden-import pkgutil --hidden-import numpy --hidden-import openvino.inference_engine.constants test.py
Output:
(openvino_env) D:\srujit_exp\dist>test.exe
(openvino_env) D:\srujit_exp\dist>
I am not getting any prints on the terminal. Can I know what may be the reason for this?
I am attaching the that contains the statements generated during the executable conversion.
Thanks and Regards
Anjaneya Srujit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjaneya Srujit,
For your information, I've successfully created the executable file using Python 3.7.9 together with the following packages version:
On another note, referring to this thread which discusses issues regarding PyInstaller, here are some of my suggestions for you to try out:
- Use --add-data command instead of --add-binary
- Give the following directory "C:\<openvino_env_dir>\Lib\site-packages\openvino\libs\plugins.xml;." for --add-binary or --add-data command.
- Use the same Python and its packages version as mine (Python 3.7.9, OpenVINO™ 2022.1, PyInstaller 5.4.1).
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hairul,
Can you please share the python code that you used for building the executable?
Thanks and Regards,
Anjaneya Srujit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hairul,
Thank you for sharing the code.
My issue was resolved. The executable is running with Python 3.8 now. I did some modifications in the "spec file" and ran the following pyinstaller command.
pyinstaller --clean test.spec
I am attaching the spec file in the spec format, that I used to generate the executable. In the "pathex" argument we need to specify the current working directory. I did this manually as it was not updating during the executable build process.
Output:
(openvino_env) D:\srujit_exp\dist>test.exe
Devices: ['CPU', 'GPU']
(openvino_env) D:\srujit_exp\dist>
Thanks and Regards,
Anjaneya Srujit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjaneya Srujit,
Glad to know that your issue has been resolved.
This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.
Regards,
Hairul
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page