Latest Code Tutorials

How To Install Django In Mac

7 5,944

Get real time updates directly on you device, subscribe now.

In this tutorial, I will show you How To Install Django In Mac.  Django is the web framework developed in Python. Django is the high-level Python Web framework that encourages rapid development and clean, pragmatic design. It takes care of much of a hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It is the free and open source. Some of the advantages of the Django framework are as follows.

Advantages of Django Framework

  • Ridiculously fast.
  • Reassuringly secure.
  • Exceedingly scalable.
  • Incredibly versatile.
  • Fully loaded.

Step 1: Install Python on Mac.

Python is already installed on brand new Mac, but its version is old. So what we do is to install the latest version of python using homebrew.

brew install python3

Okay, after it will complete the installation, you will type the following command to check the version. First type python3 in your terminal. Since MacOS X has already python installed, we cannot uninstall the old version because otherwise the Python 2 supported programmes will be stopped and we need to reinstall the mac. So we need to type python3 instead of python.


It will display the version, and now we can execute the python code. I am using iTerm2 so your terminal may be a different, but it does not matter with any commands anyway.

how to install python in mac

Okay, so we have successfully installed the python 3. Now, to out from the python console, we need to type exit().

Step 2: Install Pip package management system.

Pip is the package management system used to install and manage software packages written in Python. Now, install it using the following command.

sudo easy_install pip

Step 3: Install virtualenv for python.

Now, type this command in your terminal.

sudo pip install virtualenv

Okay, after installing, we need to create the virtual environment. Now you will create this folder when you are putting your other projects. Mine is desktop >> code folder. So navigate to that and type the following command. In my case, My virtualenv folder name is thanos.

virtualenv thanos

Okay, so it will install the required folders. Now, go into that folder.

cd thanos

Now, activate the virtual environment by typing the following command. Please Make sure you are in the virtual environment directory.

source bin/activate

You will see your terminal looks like below.

Create Virtual Environment in Python

So, our virtual environment has been started. Now, this is the time to install the Django Framework.

Step 4: Install Django In Mac

Okay, now stay in that folder and install Django using the following command.

sudo pip install django==2.0.3

It will download the Django project. Check the Django version using the following command.

python -m django --version

In our case, we have explicitly defined that we are installing 2.0.3. So it will display that version.

Step 5: Create the Django Project.

We need to install skeleton of the Django project. So type the following command.

Related Posts
1 of 21
django-admin startproject thanosback

Here, our project name is thanosback. Next, go into that folder.

cd thanosback

Finally, we have created the project. Now start the project server by typing the following command.

python runserver


python django tutorial

It has started the development server, and we can access it via localhost:8000

Navigate to the browser, and you will see the screen like this.

django rest framework tutorial

Step 6: Open Django on Visual Studio Code.

If you have not installed Visual Studio Code on Mac then please check out my below tutorial. 

Related Post:  How To Install Visual Studio Code On Mac

This step is optional because if you are using Visual Studio Code, then it will be helpful to you. If you are using another IDE like pycharm or editor like sublime text, then you can skip this step. First, perform the following step.

Install the Python extension.

Now, open our project in the visual studio code using the following command.

code .

Please make sure, you are at the root of the thanosback folder.

You will get the folder structure like this.

django tutorial

Finally, How To Install Django In Mac tutorial is over. Thanks!!

  1. kaixing says

    python migrate is not working
    (myproject) Teen-MacBook-Air:myproject chok$ python runserver
    python: can’t open file ‘’: [Errno 2] No such file or directory

    1. Hero David says

      are you in you project folder
      you can use “ls” to check

    2. elmizan says

      always execute with python3 if you has been install it with that version. By default, Mac always use the old version (2.x)

  2. Charlie El says

    You saved my day, thank you so much!!

    1. Krunal says

      Thanks man!!

  3. Awais Tariq says

    Hi, Very helpful indeed.
    Can you help me in setting up MSSQL Connection from Python 2.7, Django 1.8 using Virtual Env?
    I have tried whatever I could find on internet with no help.

  4. David Adler says

    I’m confused. You install python3 but then use “python” and “pip”. When I used “pip install django=2.03”
    , it wanted to install django v1 for python 2. I had to use “python3” and “pip3”. Did I miss something about getting “python” to actually invoke “python3”?

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.