0

I have installed virtualenv

sudo pip3 install virtualenv

Then created a new virtualenv

virtualenv --python=/usr/bin/python3.5 venv

It returned

Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /home/alexandra/Documents/online-store/venv/bin/python3.5
Also creating executable in /home/alexandra/Documents/online-store/venv/bin/python
Installing setuptools, pip, wheel...done.

Activated it

source venv/bin/activate

Then installed Django

sudo pip3 install django

It installed there (that is what sudo pip3 install django --upgrade returned)

/usr/local/lib/python3.4/dist-packages

Maybe that's the problem? Because it installed in python3.4 and not python3.5. But how to install Django in python3.5?

In file manage.py there is a path to python3.5 in this virtualenv.

Then I run

python manage.py runserver

It returns an error

Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named 'django'

Can anyone help me?

1
  • Don't use sudo to create the virtual environment; you'll have all kinds of problems. Commented Jun 4, 2016 at 19:07

3 Answers 3

3

When using pip to install packages inside the virtual env, do not sudo. It makes packages be installed globally. Simply remove sudo from beginning of the command and it should install it in the venv you are currently working on.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That actually helped!
0

You installed django into a system python 3.4.

When you ran install command first time without sudo, did it complain about permissions? That should have been your clue that it's not the right pip. My guess is pip3 only exists in system python and not your virtualenv. You can use which to find out, but this will work in any case:

venv/bin/pip install django

Comments

0

Don't do sudo and just use pip for installing all the packages. You have already installed python3 in your virtualenv, so there is no need of using pip3. Just do e.g. pip install django. or for other packages pip install <package_name>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.