How to add OpenVino setupvars.sh into PyCharm project?

Viewed 1568

I would like to add OpenVino setupvars.sh into a PyCharm project?

I'm working on a project usig OpenVino and in order to use OpenVino right now I am using following bash script in .bashrc

source /opt/intel/openvino/bin/setupvars.sh

However, I would like to work on the project using PyCharm which make easier to handle the project as it gets bigger.

How we can use OpenVino in a PyCharm project.

4 Answers

Work for me on Windows 10: Run CMD, then:

"\Program Files (x86)\IntelSWTools\openvino\bin\setupvars.bat"

"C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\bin\pycharm64.exe"

On macOS work too. Dont know about linux.

Here is a solution for Ubuntu

Add the setupvars.sh in bashrc file. Open terminal and write

gedit ~/.bashrc

Add these lines to the end of the file

# <<< Initialize Intel Vino environment variables <<<
source /opt/intel/openvino/bin/setupvars.sh
# <<< Initialize Intel Vino environment variables <<<

Save and open new terminal, now the current terminal has loaded the environment variables. You can verify that if you see this line in the terminal

[setupvars.sh] OpenVINO environment initialized

Open pycharm from the terminal by executing

pycharm-community

You can set this by pointing to the correct Python Interpreter in PyCharm. To get the current working Python environment, type the following lines of code in your local system.

python

>>>import sys
>>> sys.executable
<PYTHON PATH>

Make a note of this Python path and add it to File -> Settings -> Python Interpreter (In pycharm).

Hope this helps!

I think we have met the same question.

Here is my solution. Hope can help you :)

Make Your Own Interpreter File

  1. Make a new file such as python-custom.

     touch python-custom
    
  2. Open the file you just made.

     vim python-custom
    
  3. Save the following code into the file.

     #!/bin/bash
    
     args=$@
    
     # needed environment path
     . /opt/intel/openvino/bin/setupvars.sh
    
     # Path of your normal python path
     # You can find it by "which python", "which python3" or any python you used
     /usr/bin/python3 $args
    
  4. Add executable permissions for it.

     chmod +x python-custom
    
  5. Add a new interpreter in Pycharm.

    File -- Settings -- Project Interpreter

  6. When you choose the interpreter, use "/path/to/python-custom" instead of "/usr/bin/python3".

Related