pip installing in global site-packages instead of virtualenv
Funny you brought this up, I just had the exact same problem. I solved it eventually, but I'm still unsure as to what caused it.
Try checking your bin/pip
and bin/activate
scripts. In bin/pip
, look at the shebang. Is it correct? If not, correct it. Then on line ~42
in your bin/activate
, check to see if your virtualenv path is right. It'll look something like this
VIRTUAL_ENV="/Users/me/path/to/virtual/environment"
If it's wrong, correct it, deactivate
, then . bin/activate
, and if our mutual problem had the same cause, it should work. If it still doesn't, you're on the right track, anyway. I went through the same problem solving routine as you did, which pip
ing over and over, following the stack trace, etc.
Make absolutely sure that
/Users/kristof/VirtualEnvs/testpy3/bin/pip3
is what you want, and not referring to another similarly-named test project (I had that problem, and have no idea how it started. My suspicion is running multiple virtualenvs at the same time).
If none of this works, a temporary solution may be to, as Joe Holloway said,
Just run the virtualenv's pip with its full path (i.e. don't rely on searching the executable path) and you don't even need to activate the environment. It will do the right thing.
Perhaps not ideal, but it ought to work in a pinch.
Link to my original question:
VirtualEnv/Pip trying to install packages globally
Pip installing packages to global site-packages when inside virtual environment
I have a temporary workaround in place.
/etc/pip.conf
contained:
[global]
user = true
There was no local pip config file, this was causing it to always pass the --user
option. I am not sure how to configure my local file correctly, but I created it and set user = false
and will just manually pass the --user
option outside of venvs.
This doesn't feel like a proper fix, as it was working normally 2 days ago and the global file hasn't been changed in more than a month. Maybe an update broke something, who knows. If anyone else has a better solution, feel free to share.
pip installing in global site-packages instead of virtualenv
Funny you brought this up, I just had the exact same problem. I solved it eventually, but I'm still unsure as to what caused it.
Try checking your bin/pip
and bin/activate
scripts. In bin/pip
, look at the shebang. Is it correct? If not, correct it. Then on line ~42
in your bin/activate
, check to see if your virtualenv path is right. It'll look something like this
VIRTUAL_ENV="/Users/me/path/to/virtual/environment"
If it's wrong, correct it, deactivate
, then . bin/activate
, and if our mutual problem had the same cause, it should work. If it still doesn't, you're on the right track, anyway. I went through the same problem solving routine as you did, which pip
ing over and over, following the stack trace, etc.
Make absolutely sure that
/Users/kristof/VirtualEnvs/testpy3/bin/pip3
is what you want, and not referring to another similarly-named test project (I had that problem, and have no idea how it started. My suspicion is running multiple virtualenvs at the same time).
If none of this works, a temporary solution may be to, as Joe Holloway said,
Just run the virtualenv's pip with its full path (i.e. don't rely on searching the executable path) and you don't even need to activate the environment. It will do the right thing.
Perhaps not ideal, but it ought to work in a pinch.
Link to my original question:
VirtualEnv/Pip trying to install packages globally
Pip does not install in venv
I had the same problem, also with Python3.7 and Manjaro.
I found the fix in this answer for Pip won't install packages in virtualenv.
Set the "user" parameter to false in "/etc/pip.conf".
Pip packages installed inside the env and globally
First, activate the virtualenv by source {your_virtual_enviroment_name}/bin/activate
Second, install the libraries by pip install {library_name}
or pip install -r requirements.txt
if you have one.
Related Topics
Why Doesn't a Python Dict.Update() Return the Object
Matplotlib Fill Between Multiple Lines
Simple Argparse Example Wanted: 1 Argument, 3 Results
How to Activate a Virtualenv Inside Pycharm's Terminal
Is the Server Bundled with Flask Safe to Use in Production
Pip Cannot Uninstall <Package>: "It Is a Distutils Installed Project"
Function Changes List Values and Not Variable Values in Python
How to Call a Shell Script from Python Code
Python "Syntaxerror: Non-Ascii Character '\Xe2' in File"
Difference Between Len() and ._Len_()
Calculate Average of Every X Rows in a Table and Create New Table
Python Multiprocessing on Windows, If _Name_ == "_Main_"
How to Remove Packages Installed with Python's Easy_Install
How to Use Multiprocessing Queue in Python
Virtualenv --No-Site-Packages and Pip Still Finding Global Packages
Only Extracting Text from This Element, Not Its Children
Why Does Str(Float) Return More Digits in Python 3 Than Python 2