Dawierha
Dawierha

Reputation: 48

venv using the wrong interpreter in powershell

As the title explains, powershell uses the wrong python and pip executables in virtual environments.

I created the virtual environment using python -m venv venv and activated it with ./venv/Scripts/Activate.ps1

The activation scripts runs as expected and on the lefthand side of the shell can I see: (venv) P: C:\path indicating that the virtual environment is activated. However, when I write python or pip, powershell uses the system wide binaries instead of the ones in the virtual environment. Therefore when I try installing packages with pip they get installed system wide instead of in the venv.

I can use ./venv/Scripts/python.exe -m pip and install packages that way in the virtual environment. Though this workaround is rather tedious and wonders if anyone knows a way to fix the underlying issue?

EDIT 1: The path variable contains C:\path\to\venv\Scripts folder as the top entry. However, using the absolut path C:\path\to\venv\Scripts\python.exe does not work. Powershell says it can't find it. But the relative path as described above do work.

Upvotes: 1

Views: 458

Answers (1)

Dawierha
Dawierha

Reputation: 48

Found the problem! I had accidentally renamed the venv folder after i created it, and therefore the path was pointing to the wrong location

Upvotes: 2

Related Questions