Leoriem
Leoriem

Reputation: 11

Pip isn't installing packages in virtual environment

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.

Upvotes: 0

Views: 1809

Answers (1)

Leoriem
Leoriem

Reputation: 11

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

Upvotes: 1

Related Questions