DEV Community

Sujith V S
Sujith V S

Posted on

1 2 1 1 1

Setup python virtual environment in linux

Image description
Virtual environment is a very important tool to isolate each project modules and dependencies from other projects in our system.
Let's see how to setup python virtual environment in a linux based system.

1) First let's install virtualenv module. Open the terminal and type the below command.
$ pip install virtualenv

2) Then let's check if our virtualenv installation is successful.
$ virtualenv --version
And it should show the version and location of the virtualenv installation.
virtualenv 20.13.0 from /usr/local/lib/python3.6/dist-packages/virtualenv/__init__.py

3) Now it's time to create a virtual environment.
Move to the folder where you want to setup your virtual environment and type the following command.
$ virtualenv my_venv
Here 'my_venv' is the name of the virtual environment. You can give any name as you like.

4) After creating a 'my_venv' named virtual environment in our project folder, now let's activate our virtual environment. Enter the following command to activate the virtual environment.
$ source my_venv/bin/activate

After activation the name of your virtual environment will appear in the left side of your terminal like this
(my_venv)

Now you can install dependencies required for our projects. And now your virtual environment will isolate all the dependencies that we have installed for this project.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay