
djangoproject
Installing Django in a virtual environment
Django is an open-source MTV (Model Template View) framework written in Python for building web applications.
Get Started:
Step 1) pip
If you already have Python 2 or Python 3 installed in your computer, go ahead and verify you have pip:
In your Terminal run:
$ which pip
/usr/local/bin/pip
$ pip –version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
If you do not have pip, the run:
$ sudo easy_install pip
Step 2) virtual environment
• Install the virtual environment
$ sudo pip install virtualenv

Done! The virtual environment is installed.
• Navigate where you want to test/play with Django
Go to the main directory where you want to work.
Here are some useful commands to navigate in your Terminal:
-
pwd
-
ls
-
cd
-
cd ..
-
clear
-
mkdir
I decided to work from the Desktop:
~ $ cd Desktop
• Create a directory where you want test/play with Django
Next, create a directory where you want to work from:
:Desktop $ mkdir DjangoVM
• Name your virtual environment
It is time to name your brand new virtual environment:
DjangoVM $ virtual sandbox
I decided to name my virtual environment “sandbox” but you can name it whatever you like.
Congrats! Your virtual environment is now installed.

See it for yourself:
:DjangoVM $ cd sandbox
:sandbox $ ls
bin lib
include pip-selfcheck.json
• Entering the Virtual Environment

$ source bin/activate
(sandbox) :sandbox $
That’s it.
The name sounds cooler than what we just got. I mean, we had much more going on while installing pip or even virtualenv. Well, again, that is it.
Step 3) django
Before installing Django, let us check which version of Python we have. That way, we will pick the right Django version.
(sandbox) :sandbox $ python -V
Python 2.7.10
If you want to take a break, read this WTF Moment.

Here we are! The moment of truth. Let us run this command and install django.
(sandbox) :sandbox $ pip install django==1.11
Collecting django==1.11
Downloading Django-1.11-py2.py3-none-any.whl (6.9MB)
100% |████████████████████████████████| 6.9MB 148kB/s
Collecting pytz (from django==1.11)
Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
100% |████████████████████████████████| 512kB 1.5MB/s
Installing collected packages: pytz, django
Successfully installed django-1.11 pytz-2017.3
(sandbox) Xis-MacBook-Pro:sandbox xi$
Look at that!
I recommend this YouTube video in case you want to learn more about:
(sandbox) :sandbox $ pip freeze Django==1.11 pytz==2017.3
(sandbox) :sandbox $ pip install django --upgrade
Fun fact!
I met Kojo at PYCONCA 2017. Super cool guy who likes to talk about Django.
Here he is for you to meet:
Happy coding!
