Powershell venv only use envirnmental variables python, not python in venv directory (Windows)

Viewed 78

I use vevn with python 3.6.8, pip 18.1.

I set powershell executionPolicy RemoteSigned,

create virtual environment with venv, refed to venv official site : (https://docs.python.org/3.6/library/venv.html)

and also activated according to powershell, used .<venv>\Scripts\activate.ps1

But when I execute 'pip list' command, it shows all packages installed in global, not in venv.

And when execute python - import sys - sys.prefix, to check python directory, I can find, powershell venv uses environmental variables python.

Of course, run it on cmd in same way, it works correctly. pip list shows

The pip list shows only packages installed in venv, and sys.prefix is python in venv directory.

Does anyone know why it works like this?

Powershell works correctly like cmd

1 Answers

Maybe you activated the "--system-site-packages" switch by accident when installing the virtual env. This switch makes all python packages in the global system available to the virtual env.

Also check that after activating the environment your powershell indicates that you are actually using the virtual env. This is indicated by (env_name) at the beginning of the new power shell line.

Related