Search code examples
pythonpip

Pip does not install in venv


Virtualenv stoped working on my machine, without me knowing what I changed. It looks like pip install on global packages instead of venv. I checked all the related question on stackoverflow and could not find a answer that resolved my issue.

So here it is. I'm using Manjaro and python 3.7.

What I do :

mkdir test_venv
cd test_venv
python3 -m venv env

It effectivly creates the folder env with all the good stuff. The $VIRTUAL_ENV in the env/bin/activate is good "/home/MyName/PythonProjects/test_venv/env"

which pip

before activating the venv it returns /home/MyName/.local/bin/pip

source env/bin/activate

I'm effectivly entering the venv

which pip

returns /home/MyName/PythonProjects/test_venv/env/bin/pip and same for python3

pip install requests

Installing collected packages: certifi, idna, urllib3, chardet, requests

Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3

And pip-freeze return nothing and trying to do an import requests in a test.py file return "No module named requests"

Do you have any ideas what could I try ? I tried to reinstall python-pip package with pacman, changed nothing.

Thanks ! Have a good day


Solution

  • 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".