DEV Community

Dhanraj K
Dhanraj K

Posted on

How to Setup a Python Virtual Environment

Virtual Environment is necessary when you have many projects with different requirements, You can use python2 or python3 without worrying about collision and keep then main python folder clean

Install python virtual environment

>> sudo apt-get install updates
>> sudo apt-get install python3-venv
Enter fullscreen mode Exit fullscreen mode

Create project folder

>> mkdir project_folder_name
>> cd project_folder_name/
Enter fullscreen mode Exit fullscreen mode

Initialize a virtual environment

>> python3 -m venv virtual_env_name
Enter fullscreen mode Exit fullscreen mode

To activate virtual_env

>> source virtual_env_name/bin/activate
Enter fullscreen mode Exit fullscreen mode

To deactivate virtual_env

>> deactivate
Enter fullscreen mode Exit fullscreen mode

Top comments (0)