Coding / Programming Videos

Post your favorite coding videos and share them with others!

Tutorial #2 — Setting Up Python Virtual Environment and pip packages for Django Application

Source link

Step 01: Installing Miniconda to Setup Virtual Environment

We use Miniconda to manage virtual enviroments corresponding to different python versions. It is a miniature version of Anaconda which doesn’t come preinstalled with packages (so we can install as per our need). We use python-3.5 version in our server-side code. Download the appropriate Miniconda distribution pertaining to your OS. (Any python version will suffice, as we would create a seperate python-3.5 environment)

Go to the directory where file is downloaded.

$ chmod +x <file_name>  
$ ./<file_name>

Or, you may directly download and install miniconda through the below commands.

$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ chmod +x Miniconda-latest-Linux-x86_64.sh
$ ./Miniconda-latest-Linux-x86_64.sh

After installation, we set up virtual environment for python-3.5 as:

conda create -n py35 python=3.5

Commands for activating and deactivating the environment are:-

  • Activation: conda activate py35
  • Deactivation: conda deactivate

Step 02: Installing basic pip packages to run Django Application

Activate the virtual environment using conda activate py35 and follow the steps below. We will be explaining the packages in detail , when they will be used. Since it is just environment setup guide, You may install the packages without going into the details. We recommend using the specific version numbers so as to avoid any incompatibility issues. However, readers are free to try out the latest version and let us know in case of any issue.

Django Framework

pip install django==2.0.3

Django Import-Export

pip install django-import-export==1.2.0

Django Rest Framework

pip install djangorestframework==3.9.1

Django Rest Swagger : For API Documentation

pip install django-rest-swagger==2.2.0

Psycopg2 : For Postgres Configuration

pip install psycopg2==2.7.7

Pillow : Python Imaging Library

pip install Pillow==5.4.1

PyJWT : Token Authentication

pip install PyJWT==1.7.1

Django Cors-Headers : Allow developers to make cross-domain requests

pip install django-cors-headers==2.2.0

Hope you have setup python and it’s dependencies, revert back to us for any issues, we will continue with Postgres Database Configuration in upcoming posts.

For Regular Updates and other blogs of the this tutorial series. You may Follow — React DJ Facebook Page

For Introduction of the Tutorial Series You may read — Building Practical Web Applications with React & Django

Source link

Bookmark(0)
 

Leave a Reply

Please Login to comment
  Subscribe  
Notify of
Translate »