Skip To Main Content
Support Knowledge Base

Unable to Run OpenVINO™ Sample in Visual Studio* (VS2019 / VS2022)

Content Type: Troubleshooting   |   Article ID: 000058525   |   Last Reviewed: 03/05/2026

Description

  1. Tried to run an OpenVINO™ sample from within Visual Studio* (VS2019 or later)
  2. Encountered error: no module named 'openvino'

Resolution

The OpenVINO™ environment variables must be set before running an OpenVINO™ application.

Run setupvars.bat (Classic OpenVINO installations) or setvars.bat (OneAPI-based installations) in the terminal or environment in which the program will run.

Follow the OpenVINO™ installation guide to ensure the toolkit is installed correctly.

There are two options to implement this with VS2019:

Option 1:

VS Developer Powershell*

  1. Open VS Developer PowerShell.
  2. Run the OpenVINO™ environment setup script:
    <OpenVINO_install_path>\setupvars.bat (For oneAPI installations, use setvars.bat).
  3. Launch Visual Studio from the same terminal: devenv.exe.
  4. Open <your sample> from the OpenVINO™ folder in Visual Studio
  5. Create a backup of the code if necessary.
  6. Set <your sample> as the startup item.
  7. Run the sample application.

Option 2:

Automate OpenVINO™ Setup and Visual Studio Initialization.

Create a batch file that initializes the OpenVINO™ environment and opens Visual Studio.

Write the script below in a .bat file:

@echo on
cd <OpenVINO_install_path>\bin
CALL setupvars.bat

cd <Microsoft Visual Studio location>\Common7\IDE
CALL devenv.exe

(For oneAPI installations, replace setupvars.bat with setvars.bat)

Steps:

  1. Run the .bat file (administrator privileges may be required).
  2. After Visual Studio opens, select <your sample> from the OpenVINO™ folder.
  3. Create a backup file if necessary.
  4. Set <your sample> as the startup item.
  5. Run the sample application.

Related Information

OpenVINO™ Installation Guide Visual Studio Development Documentation

Related Products

This article applies to 1 products.