[Python] Why does Visual Studio Code use global python config despite pointing to my virtual...

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have a workspace folder, with a virtual environment under /venv/ I have an older version of opencv-python installed here (3.4.6.27) than what I have globally (4.4.0.46). However, despite pointing visual studio code to my venv, inspecting the version shows the higher one.

    I.e., When I activate the venv in a terminal, then

    pip list


    I get this

    Package Version
    ------------- --------
    numpy 1.19.4
    opencv-python 3.4.6.27
    pip 20.1.1
    setuptools 47.1.0


    But in a visual studio notebook:

    import pkg_resources
    pkg_resources.get_distribution("opencv-python").version


    provides

    '4.4.0.46'


    When I click to select to the interpreter, it is pointing to the correct path.

    Current: ~/Desktop/workspace/venv/bin/python


    So what am I missing?

    Continue reading...

Compartilhe esta Página