profile for Gajendra D Ambi on Stack Exchange, a network of free, community-driven Q&A sites

Thursday, January 26, 2017

Starting with your python django on centos 7

So you can directly install django framework or using yum or the beta version but most prefer to go the pip using virtual environments since you can have multiple versions of python without them affecting the other projects.
python django + pip + virtualenv has all the advantages of every other method + more. So let us go with this shall we?

yum install epel-release 
will get us access to epel repository. I additionally also would have rpmforge
but not necessary for now.
yum update -y
will update your centos with all the relevant packages. It is a good thing to start with always.
Let us get the pip for python
yum install python-pip
once we got the pip then we can get the python django by
pip install django
you may check the version by running
django-admin --version

then install the virtual environment by

pip install virtualenv

Now we have all the necessary components installed, let us get busy.
Let us create a new directory for our new project project1 and get inside it
mkdir ~/project_test
cd ~/project_test
Create a new virtual environment within this project directory
virtualenv test_env
okay now inside this test_env you have a standalone pip and python installed. let us activate it to use it.
source test_env/bin/activate
you will be automatically moved into this new environment.
let us install django locally in this virtual environment.

pip install django

If you now want to leave the virtual environment then you can deactivate it and 
activate it when you want to get back in.