idepython-importpython-venvopenvino

venv not wokring in Wing Personal 9 IDE


I'm trying to run this Python OpenVINO code snippet in Wing Personal 9 IDE for testing the installation.

from openvino.runtime import Core 

ie = Core()
devices = ie.available_devices
for device in devices:
    device_name = ie.get_property(device, "FULL_DEVICE_NAME")
    print(f"{device}: {device_name}")

It works in terminal from a virtual environment but no matter what I try in Wing, including starting a new project, I always seem to get builtins.AttributeError: partially initialized module 'openvino' has no attribute '__path__' (most likely due to a circular import) and builtins.ModuleNotFoundError: No module named 'openvino.runtime'; 'openvino' is not a package errors. Could someone tell how to make venv virtual environments work with Wing Personal 9? I have read the two pages from Wing website advicing on this but it just doesn't work.


Solution

  • If you are using virtualenv to set up your Python environment, you don't need to set Python Path. Instead, set Python Executable to Activated Env and enter the command that activates your environment.

    Based on your encountered error, it is due to you are running a Python script which its name conflicts with the OpenVINO package name.

    Rename your Python script (openvino.py) to any name except ‘openvino’.