DEV Community

Cover image for What's An Virtual Environment
Manoj Sadanala
Manoj Sadanala

Posted on

What's An Virtual Environment

Virtual Environment

Virtualenv will isolate your Python/Django setup on a per-project basis. This means that any changes you make to one website won't affect any others you're also developing.
Installing packages globally can be avoided by Virtual Environment.
when a virtual environment is active, the packages will be installed within the environment and not in the whole system.

Installing Virtual Environment
In the terminal of your mac entering the command below in working directory, which installs it in your working directory

python3 -m venv myvenv

  • Here, myenv is the name of our virtual environment

  • We can keep any other names, lower case letters are suggestable.

Running Virtual Environment and Working In It
Running the below command in the directory we installed our virtual environment will activate or start the virtual environment

source myvenv/bin/activate

  • Here we should replace myenv with the name of the virtual environment with the name we used for virtual environment

_When we start the virtual environment, we can identify that it started when you see the prompt in your terminal or console is prefixed with (myenv) like this, _

(myvenv) manoj@Manojs-MacBook-Air ~ %

We had successfully understood the way to install a virtual environment in a directory and how to make it running

Top comments (0)