简体   繁体   English

从 PyCharm 导入 OpenVINO

[英]Import OpenVINO from PyCharm

My setup is the following:我的设置如下:

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

I am trying to import OpenVINO:我正在尝试导入 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):这会导致在 PyCharm 中运行时出现以下错误(即使用播放按钮时的 PyCharm 配置):

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:如果我从 PyCharm 终端运行相同的文件,它就可以正常工作:

python3 test.py

How can I have it working with PyCharm?如何让它与 PyCharm 一起使用? I would need to debug some code.我需要调试一些代码。

Please take note that every OpenVINO toolkit usage requires the initialization of setupvars.sh.请注意,每次使用 OpenVINO 工具包都需要初始化 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.我相信,您已经在终端中初始化了 OpenVINO 环境。 Maybe you have s ource intel/openvino_2021/bin/setupvars.sh in your .profile file.也许您的.profile文件中ource intel/openvino_2021/bin/setupvars.sh 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. OpenVINO package 中的脚本bin/setupvars.sh将环境变量(首先是PYTHONPATHLD_LIBRARY_PATH )设置为 OpenVINO 二进制文件。 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因此,您需要从终端处理此变量的值,并将此变量的值与您在 PyCharm 中的配置一起处理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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