I have set up a virtual environment correctly have activated it and when I do "which python" it tells me the correct directory, but when I do pip install in the venv it installs the package in the default directory of the mac and not in my venv. I have tried using pycharm and installing packages with that, but it happens the same thing.
Edit:
Following I will do a walkthru of my steps, first I did python3 -m venv /path/to/new/virtual/environment
, then I did source env/bin/activate
, then I did which python
and I got the intended directory, afterwards I did pip3 install numpy
and I saw the installation process, then I did pip list
and numpy was not there, I checked the directory manually and it still was not there. I retried all the same thing with pycharm with the same results.

- 85
- 9
-
1Did you activate the virtualenv before installing the packages? – Kaushal panchal Feb 04 '22 at 08:24
-
As you may imagine, probably they are doing the correct thing, but you are either executing things wrongly or a wrong assumption. But we cannot tell you anything: your question is vague. What did you do? (exact commands). What you expect? What you got? With such information we may help. – Giacomo Catenazzi Feb 04 '22 at 08:24
-
1Can you try `python -m pip install ...`? You might use a wrong pip binary. To list your packages, `python -m pip list` – Thy Feb 04 '22 at 08:26
-
"Did you activate the virtualenv before installing the packages?": yes I did – Riccardo Piana Feb 04 '22 at 08:28
-
Check if you get the right pip using `which pip` too – Thy Feb 04 '22 at 08:29
-
"Can you try python -m pip install ...? You might use a wrong pip binary. To list your packages, python -m pip list": I just tried, still saying it installed but not installing – Riccardo Piana Feb 04 '22 at 08:31
-
"As you may imagine, probably they..." Ill edit my post to provide more detail – Riccardo Piana Feb 04 '22 at 08:32
-
1What do you mean with "but not installing"? Do you see the package using `python -m pip list`? – Thy Feb 04 '22 at 08:34
-
if i do python -m pip install numpy while in my activated directory it will do all the process of installation but then when I do python -m pip list it is not there, if I check the folder manually it is still not there – Riccardo Piana Feb 04 '22 at 10:36
2 Answers
Follow these steps in order -
In your current working directory :
python3 -m venv venv
source venv/bin/activate
(venv) pip3 install library_name
To check if libraries were properly installed or not :
(venv) pip3 freeze
and check if your installed libraries is displayed on the terminal screen or not.
To deactivate the virtual environment :
(venv) deactivate

- 83
- 6
This is due to permission issues
Run this command to change permission of your virtual environment folder
sudo chmod -R 777 venv
After activating your virtual environment
source venv/bin/activate
Then try to install Django by either Python3 or Python2
pip3 install django or pip install django
Then check the list of installed packages by either Python3 or Python2
pip3 list or pip list
NOTE: If you run sudo pip3 install django or pip install
in virtual environment that is not writeable by default it will be installed outside of virtual environment
If you run pip3 install django or pip install
in virtual environment that is not writtable by default it will be installed outside of virtual environment you will get OS Persmission Error
I have used pip3 and pip
because you can install packages by either Python3 or Python2
, thing to remember if you created virtual environment by Python3, use pip3 and if you created by using Python2 use pip
.

- 84
- 5
-
Why should anyone rewrite permissions over default ones for venv folder? Why should someone referring to python3 at all times, want to install something with python2 (therefore not compatible with python3)? Also, you cannot be sure that `pip` refers to python2 pip without checking the alias first. Finally, you never talk about activating the venv in your steps, so any command you execute will still be outside your venv. You're probably installing things in your global python installation (or one of them). Your steps are imprecise and probably not produce the desired output. – Btc Sources Nov 11 '22 at 06:10