question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

in virtual environment pip installs in global instead of virtual environment on Windows 10

See original GitHub issue

Description

When I create a virtual environment with venv: py -m venv my_env and activate it, pip installs packages in the global site-packages of current python instead of venv site-packages I used pip install <package> and path/to/my_env/Scripts/python.exe -m pip install <package> but none of them worked.

I googled and checked activate file and the path was ok. Also a manual solution for every environment does not work for me as I want to use ‘Pycharm env’ and install platformio for vscode (as it first create virtual env then starts installing packages)

I even reinstalled my python but it didn’t worked. I don’t know if it’s related to pip.ini setting.

I have no idea what to do…

Expected behavior

I expected pip to install packages in path/to/my_env/Lib/site-packages instead of glabal python site-packages

pip version

22.0.4 (in virtual env, global is 22.1.1)

Python version

3.9.13

OS

Windows_NT, 10.0.19044, x64

How to Reproduce

py -m venv my_env [or ‘py -m virtualenv my_env’] my_env\Scripts\activate.bat pip install Django [or ‘my_env\Scripts\python.exe -m pip install Django’]

Output

No response

Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
SaeedRezaAmanatcommented, Jun 1, 2022

I don’t know how you got that setting, it’s definitely not recommended. I’d suggest you remove it - that should fix your issue.

That was strange for me too. I had noticed that but I thought it was the default setting. Anyway removing pip.ini in the specified directory actually solved my problem! Thank you very much for your help!

0reactions
uranusjrcommented, Jun 1, 2022

Oh, I misread your previous comment! You were talking about disallowing setting those configs; I was thinking about let pip not run with those configs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing packages using pip and virtual environments
This guide discusses how to install packages using pip and a virtual environment manager: either venv for Python 3 or virtualenv for Python...
Read more >
PIP installing globally instead of virtual env - Stack Overflow
In the terminal where you have activated your virtual environment. Is this where you are running your pip install command? · Any chance...
Read more >
Fix: Pip installs packages globally instead of virtual env
There are multiple reasons why pip installs packages globally instead of in a virtual environment: ... The first thing you should do is...
Read more >
Further Configuration of pip and Virtualenv
As a result of this, it is very easy to install packages globally while thinking that you are actually installing the package for...
Read more >
pip installs packages globally when used in virtualenv but ...
pip installs packages globally when used in virtualenv but inheriting global packages. PC-193.5233.109, JRE 11.0.4+10-b520.11x64 JetBrains s.r.o, OS Windows ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found