Virtual Environment is an environment where the developers or programmers can avoid the global dependency of library packages installed in python. Virtual environments are effective when, the software has to be shipped as whole without creating any dependency issues.
Here we can learn about how to create Virtual environment using CMD (multi-step) and Pycharm(quicker π ). Lets go!
CMD:
- Installing Virtual Environment type: βpip install virtualenvβ

2. Verify installed version using βpython -m virtualenv βversionβ

3. Now lets create a folder as a virtual environment, by βpython -m virtualenv <foldername>β, eg: βpython -m virtualenv pandatestingβ

4. We can activate the environment by, go to Scripts folder available in virtual environment and run βactivate.batβ

5. Let try installing a package inside the virtual environment. βpip install pandasβ

6. OK, but if I want to install multiple packages and even some with particular version, how could I do it.. Hmm.. the answer is requirement. Lets see the snip of how requirements looks like,

Now copy the file to virtual folder and install using below command βpip install -r requirements.txtβ

Now the Virtual environment is ready for you!
Pycharm
Now, lets do the quicker way using pycharm,
- Create a new project in pycharm

2. Create Virtual Environment using PyCharm

3. You can see the virtual environment is created and now you can add requirements.txt

4. When you open a requirements.txt, you could see the package requirement inspection (image of bulb) pops up and give you the status of package installed.

One thought on “How to Create Virtual Environment in Python 2.7”