I have created virtual environment with python 3.6.Trying to install django with pip.When I run pip install django command, it prompts that requirement already satisfy but I cannot find the django in pip list.
$pip install django
Requirement already satisfied: Django in /usr/lib64/python2.7/site-packages
(1.11.21)
Requirement already satisfied: pytz in /usr/lib/python2.7/site-packages (from
Django) (2019.1)
when I try to check django version on python shell .
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
Even i have checked in /usr/lib/python2.7/site-packages dir, i cannot find django. How do I fix this?
Asked
Active
Viewed 1,609 times
0

ifte
- 33
- 6
-
Is the pip you are using the correct version for your Python **3.6** installation? Your error message talks about Python **2.7**. Maybe try pip3? – Ocaso Protal Aug 21 '19 at 14:02
-
1Activate the virtual environment first. Then install Django with `python -m pip install django`. – Alasdair Aug 21 '19 at 14:13
3 Answers
1
Activate the virtual environment first, for example:
source /path/to/virtualenv/bin/activate
Then install Django with
python -m pip install django

Alasdair
- 298,606
- 55
- 578
- 516
-
I have activated virtual env. using command 'python3 -m venv env '. Then install Django with 'python -m pip install django '. It shows that Django is installed successfully. But, pip list does not display Django packages – ifte Aug 21 '19 at 14:58
-
You say *using command `python3 -m venv env`* - that creates the virtual env, it doesn't activate it. Activate it with `source`. If you use `python -m pip install django`, then use `python -m pip list`. If that doesn't work, then add more information to you original question because it's not clear from your comments exactly what is going on. – Alasdair Aug 21 '19 at 15:34
0
Indeed, as stated by Ocaso Protal, if you are not using python 2.7, don't use pip but pip3
pip3 install django

Oka
- 101
- 6
-
1`pip3` will install the package for Python 3, but it won't use the virtual environment if it hasn't been activated. The key thing is to activate the virtual environment first. Once inside the virtual environment, you can use `python` and `pip` instead of `python3` and `pip3`. Using `python -m pip install` instead of `pip install` makes sure that you are installing the package for that version of Python. – Alasdair Aug 21 '19 at 14:17
-
@Alasdair my bad did no read properly and i thought it was simpler than that, I did no see that in was in a venv, Thanks ! – Oka Aug 21 '19 at 14:20
0
I've had this issue a few times, and just rebooting fixed it each time when I install a package and then cannot import it.

VodkaBottle
- 34
- 3