[Python] Can I have different virtual environments in a project managed by uv?

Discussão em 'Python' iniciado por Stack, Janeiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    On a Windows machine, I'm developing a Python project that I manage using uv. I run the unit tests with uv run pytest, and uv automatically creates a virtual environment in .venv. So far, so good.

    But every now and then, I want to run the unit tests - or other commands - in Linux (from the same project source directory). In my case, this means WSL, but it could also be a VM using a shared folder or a network share. The problem is that the virtual environment is platform specific, so uv run pytest reports an error that the virtual environment is invalid.

    Is it possible to configure uv to use a different name for the project's virtual environment - e. g., .venv_linux?

    As a workaround, I could move the .venv folder out of the way and let uv on Linux create its own .venv. But I'd have to do that every time I switch between the two, and that would be cumbersome. I also couldn't do this while a command from the project is still running.

    Continue reading...

Compartilhe esta Página