I'm running CentOS, and it has pre-installed Python 2.6.6. But I want to use Python 3.5, the latest version. So I have installed Python 3.5 on my server. It's working properly.

I just compile Python code like this:

Python 2.6:

python file.py

Python 3.5:

python3.5 file.py

These commands compile my code with the specific versions.

But I want to install Django with Python 3.5.1. For example, if I use

pip install Django

I know it will install Django, but will it install Django with pre-installed Python 2.6 or the latest 3.5?

How can I force pip to install Django with Python 3.5?

1 Answer 1


What you should do is install Django in a virtualenv and not directly in your python installation (2.6 nor 3.5). Where you install virtualenv is not important (it probably goes into the 2.6 install):

pip install virtualenv

now create a 3.5 virtualenv by doing:

virtualenv -p $(which python3.5) /opt/django

(adapt the /opt/django to your needs), and then install within this 3.5 based virtualenv:

/opt/django/bin/pip install django

or first activate the virtualenv (in Bash) and then install

source /opt/django/bin/activate
pip install django

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.