Basic Python Virtual Environment Setup

Django Project Set Up

  1. Choose code editor platform like Visual Studio(recommending), Sublime Text, PyCharm, Atom or Vim.

  2. Install Python 3.10 (at least)

  3. Set the Environment Path for python interpreter.

  4. Create a Folder name "Djnago Todo App with User Authentcation"

  5. Open created folder "Djnago Todo App with User Authentcation" in visual studio code.

  6. Open Terminal in vs code (ctrl + `) and change terminal from from powershell to cmd like given below (ref Fig. 1.1)

Fig 1.1 Terminal in cmd
  1. using python to create a virtual environment for your project namely "pyvenv"

Type below code in your cmd prompt (ref Fig. 1.2)

py -m venv pyvenv
Fig. 1.2 Python Virtual Environment
  1. Now activate your python virtual environment in terminal.

Type below code in your cmd prompt (ref Fig. 1.3)

call pyvenv/Scripts/activate
Fig. 1.3 Activating python virtual environment.
  1. Create "requirements.txt" file in "Djnago Todo App with User Authentcation" folder. (ref Fig. 1.5)

Fig. 1.4 Creating requirements.txt in root folder.
  1. Save the below lines in requirements.txt file.

asgiref==3.7.2
Django==4.2.9
sqlparse==0.4.4
tzdata==2023.4
Fig. 1.5 Collecting Requirements
  1. Install the requirements.txt using python package manager (pip) in your virtual environment (pyvenv)

Type below code in your cmd prompt (ref Fig. 1.6)

pip install -r requirements.txt
Fig. 1.6 Installing Requirements.
  1. Now check the requirements are successfully installed.

Type below code in your cmd prompt (ref Fig. 1.7)

pip freeze
Fig. 1.7 Checking Requirements in pyvenv

Last updated