简体   繁体   中英

Import OpenVINO from PyCharm

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 (ie 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.

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 .

I believe, that you have initialised OpenVINO environment in the terminal. Maybe you have s ource 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM