Should I commit my virtualenv to Github?

Asked

Viewed 1,359 times

5

I did a project in Python using a virtualenv, in this case I should upload all virtualenv to Github or just the Python code?

2 answers

9


I don’t recommend that you upload your virtual environment to your Git repository.

Instead, use the command pip freeze to get a list of all packages used in your virtual environment and save the output to the archive requirements.txt. This file yes, should be sent to your repository. Using pip install -r requirements.txt in a new virtual environment, you will be able to reinstall all packages needed for your project (in the correct versions including).

The ideal would be to set up a file .gitignore in your project’s root folder to ignore virtual environment files. If your virtual environment is inside the folder venv for example, add venv/ in the .gitignore and save. You can download a file .gitignore well-rounded here.

2

In general, do not upload dependency content that can easily be downloaded. Try to write a README.Md clarifying, describing the procedures for obtaining the modules on which the program depends, its installation and examples of use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.