0

On windows, with python 3.9.5.

I create a virtual environment using python -m venv env. I activate it, no problems. I verify that when using pip and python I use those of my virtual environment, no problems here.

I type python -m pip install wheel. Because I'm still using venv, pip should try to install in .\env\Lib\site-packages, yet pip is trying to install it in C:\Program Files\Python39\Lib\site-packages.
I have the same results when using pip install wheel

Can somebody explain what is wrong and what should I do to solve this?

Commands and outputs:
python -m venv env --> folder created

.\env\Scripts\activate --> virtual environment activated

where python --> C:\Users\user\Documents\env\Scripts\python.exe and C:\Program Files\Python39\python.exe

pip -V --> pip 21.1.1 from c:\users\user\documents\env\lib\site-packages\pip (python 3.9)

python -m pip install wheel -->

Collecting wheel
Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.0

WARNING: Target directory C:\Program Files\Python39\Lib\site-packages\wheel already exists. Specify --upgrade to force replacement.
WARNING: Target directory C:\Program Files\Python39\Lib\site-packages\wheel-0.37.0.dist-info already exists. Specify --upgrade to force replacement.
WARNING: Target directory C:\Program Files\Python39\Lib\site-packages\bin already exists. Specify --upgrade to force replacement.

Leoriem
  • 11
  • 4

1 Answers1

1

We can force pip to install the packages where we want using the -t parameter

Example:

  • go to env\Lib\site-packages
  • use pip install -t . package or python -m pip install -t . package

It should work correctly after that

Leoriem
  • 11
  • 4
  • True but this could cause problems if not using the right pip for the right Python environment. It would be better to resolve the underlying issue which, like many questions like this, is probably hard to determine without some interactive debugging, as it's probably some combination of environment configuration issues. – Iguananaut Aug 19 '21 at 17:09