Python Create Virtual Environment

Python has an inbuild venv module to create a lightweight virtual environment, it will help us to isolate and run multiple projects with different dependency. virtual environment is created on top of an existing python installed in the system.

Python …


This content originally appeared on DEV Community and was authored by Max

Python has an inbuild venv module to create a lightweight virtual environment, it will help us to isolate and run multiple projects with different dependency. virtual environment is created on top of an existing python installed in the system.

Python virtual environment is kind of similar to docker but both are different. Docker is used to create isolated environment with different OS version and type, System dependency, different python and node version. VENV is used to created environment for python packages.

Suppose if we want to run a django and flask project instead of installing both packages globally, seprate virtual environment can be used to run the project. In future if we want to create a new project without affecting the existing project this comes handy.

Syntax

python -m venv [venv]

you can have any name as you want inside the square bracket []

Steps:

  1. Go to the folder where you want to create the new virtual environment.
  2. Run this command python -m venv venv

To activate virtual environment in Linux or Mac use this command

source venv/bin/activate

To activate virtual environment in Windows use this command

.\venv\Scripts\activate

Learn more about python tutorials

Explore Other Related Articles

Read and Write JSON in Python Requests from API
Read and Write Python Json
How to combine two dictionaries in python using different methods
How to check if a key exists in a dictionary python
Python try exception tutorial
Python classes and objects tutorial


This content originally appeared on DEV Community and was authored by Max


Print Share Comment Cite Upload Translate Updates
APA

Max | Sciencx (2023-03-11T13:21:55+00:00) Python Create Virtual Environment. Retrieved from https://www.scien.cx/2023/03/11/python-create-virtual-environment/

MLA
" » Python Create Virtual Environment." Max | Sciencx - Saturday March 11, 2023, https://www.scien.cx/2023/03/11/python-create-virtual-environment/
HARVARD
Max | Sciencx Saturday March 11, 2023 » Python Create Virtual Environment., viewed ,<https://www.scien.cx/2023/03/11/python-create-virtual-environment/>
VANCOUVER
Max | Sciencx - » Python Create Virtual Environment. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/11/python-create-virtual-environment/
CHICAGO
" » Python Create Virtual Environment." Max | Sciencx - Accessed . https://www.scien.cx/2023/03/11/python-create-virtual-environment/
IEEE
" » Python Create Virtual Environment." Max | Sciencx [Online]. Available: https://www.scien.cx/2023/03/11/python-create-virtual-environment/. [Accessed: ]
rf:citation
» Python Create Virtual Environment | Max | Sciencx | https://www.scien.cx/2023/03/11/python-create-virtual-environment/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.