Install Django on Mac with PIP and VirtualEnv

PIP is Python’s package installer. ¬†VirtualEnv is a package within Python. ¬†You don’t have to install or use virtual environment (virtualenv). It makes your life easy when you move from one computer to another. You can simply copy your virtual folder to where you want to work and all of your settings will be ported.

To install PIP, execute the following
$ sudo easy_install pip

To install virtualenv – Python’s package, execute the following
$ sudo pip install virtualenv

To create a virtual environment, go to the folder where you want to create your environment and execute the following
$ virtualenv myXYZprojectWork

Go to myXYZprojectWork folder. You will see subfolders (/bin, /include, and /lib) created under myXYZprojectWork.

To get in to the virtual environment, execute the following
$ source bin/activate

To check what packages are installed in the virtual environment, execute the following
$ pip freeze

To install the latest version of django, exute the following
$ pip install django

To upgrade django to the latest version, execute the following
$ pip install django –upgrade

Within your virtual environment, you can create your project executing the following
$ django-admin.py startproject myProject

The process will create a project and a subfolder called myProject.

To start the server with your project within the virtual environment, go inside myProject folder and execute the following
$ python manage.py runserver

To check your django server running, browse to http://127.0.0.1:8000/

Install Django on Mac with PIP and VirtualEnv

Leave a Reply

Your email address will not be published. Required fields are marked *