Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Installing Python Packages Into a Virtual Environment

Give Feedback

This lesson covers how to download and install third party Python packages into a virtual environment using the pip tool. You’ll also see the correct way to use pip while the virtual environment is active.

Omer Faruk on April 20, 2019

Hi, Thanks for the nice video. Could you please show how we can initialize git repository while the virtual environment i active.

Jim Anderson RP Team on April 20, 2019

Hi, Omer! git is largely unaware of Python virtualenvs. (Unless you’re calling git from python directly, but that doesn’t sound like what you’re doing :) )

If you need a git refresher, the commands for initializing and using git are covered in our Intro to Git article

Omer Faruk on April 20, 2019

Thank you Jim. I am using some git commnds but I did not use them with virtual environment. For instance, I have a simple Python project:

HelloWorld — venv — bin — include — lib — pyenv.cfg — example1.py — example2.py

In order to add this project to version control, I am planning to follow the steps below. I am not sure whether this is a correct way. I also wonder best practices. 1- cd HelloWorld 2- init git repository 3- add venv directory into .gitignore file

Jim Anderson RP Team on April 20, 2019

That sounds like a good approach. You don’t want the venv in your repo. You should think about a requirements.txt file to store what dependencies you have and THAT can be in the repo.

Hope that helps!

rehdwolfe on July 5, 2019

Do you happen to have a link handy for using requirements.txt?

Dan Bader RP Team on July 5, 2019

shevachp on March 15, 2020

Thanks. Very very (not a type) helpful. I would like to know how can I code in IDLE in the virtual enviroment. Thanks

Ricky White RP Team on March 16, 2020

Hi shevachp. IDLE is not made for writing production code in and therefor not for writing apps in virtual environments. I would recommend you upgrade to a more extensive code editor or IDE. We have a guide on IDEs and editors here: realpython.com/python-ides-code-editors-guide/

Hope that helps.

Become a Member to join the conversation.