3

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.

HopeAI
  • 61
  • 5

4 Answers4

3

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.

Community
  • 1
  • 1
3

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
TripleS
  • 1,216
  • 1
  • 23
  • 39
1

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 tried this, however, I was not able to import openvino in PyCharm projects. Right now, I'm using PyCharm for development but I run source codes using terminal. – HopeAI Jun 26 '19 at 13:45
1

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".

QuarTerll
  • 11
  • 2
  • What is the "/opt/nuclio/common" path? I don't have it on my Mac – user1315621 Dec 10 '20 at 17:52
  • @user1315621 That is a mistake. The path is used for my project. Just remove it and have a try. (I have re-edited it) This shell is going to run your python codes with the shell including your environment, such as setupvars.sh here, instead of normal "/usr/bin/python" – QuarTerll Dec 14 '20 at 07:14