Import OpenVINO from PyCharm

532 Views Asked by At

My setup is the following:

  • macOS Big Sur
  • pyenv
  • PyCharm + venv
  • Python 3.7.7
  • OpenVINO 2021.1.110

I am trying to import OpenVINO:

import openvino
from openvino import inference_engine

This results in the following error when running in PyCharm (i.e. PyCharm configuration that is when using the Play button):

Traceback (most recent call last):
  File "/Users/myuser/code/test.py", line 2, in <module>
    from openvino import inference_engine
  File "/Users/myuser/.pyenv/versions/3.7.7/lib/python3.7/site-packages/openvino/inference_engine/__init__.py", line 1, in <module>
    from .ie_api import *
ImportError: dlopen(/Users/myuser/.pyenv/versions/3.7.7/lib/python3.7/site-packages/openvino/inference_engine/ie_api.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libinference_engine.dylib
  Referenced from: /Users/myuser/.pyenv/versions/3.7.7/lib/python3.7/site-packages/openvino/inference_engine/ie_api.cpython-37m-darwin.so
  Reason: image not found

If I run the same file from the PyCharm terminal it works just fine:

python3 test.py

How can I have it working with PyCharm? I would need to debug some code.

2

There are 2 best solutions below

0
On

Please take note that every OpenVINO toolkit usage requires the initialization of setupvars.sh.

You can set it permanently or if not, you need to initialize it each time you open a new terminal.

Make sure that the initialization message appears when you init it. It should appear automatically each time you open a new terminal if you had set it permanently.

Just to be sure, make sure that you had everything done according to this guide.

0
On

I believe, that you have initialised OpenVINO environment in the terminal. Maybe you have source intel/openvino_2021/bin/setupvars.sh in your .profile file. The script bin/setupvars.sh inside the OpenVINO package set up environment variables (first of all PYTHONPATH and LD_LIBRARY_PATH) to the OpenVINO binaries. So you need to cope the values of this variables from the terminal and past this variables with the value to your configuration in PyCharm