[Python] Why does PyLance fail to resolve imports from UV-managed virtual environments in...

Discussão em 'Python' iniciado por Stack, Julho 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using UV as my Python package manager to manage dependencies and virtual environments in my projects. Everything works fine when I use the default Python version, but recently I switched to a different Python version for my workflows.

    After changing the Python version, PyLance in VS Code started showing errors like:

    Import "<package_name>" could not be resolved
    Import "<package_name>" could not be resolved from source


    These packages are correctly installed in the UV-managed environment, and my code runs without issues from the terminal. However, PyLance doesn't seem to recognize them.

    My questions:
    Is PyLance compatible with virtual environments created and managed by UV? Do I need to install packages using pip instead of UV for PyLance to recognize them? Is there a way to configure PyLance or VS Code to work properly with UV environments?

    Continue reading...

Compartilhe esta Página