I am pretty new in Python and I have the following doubt related publishing a Python project on a GIT repository: have I to avoid to publish also the venv folder on my GIT repository or is it good to put also this folder into the repository?
-
1Does this answer your question? [Virtualenv and source version control](https://stackoverflow.com/questions/9586346/virtualenv-and-source-version-control) – AMC Feb 20 '20 at 16:08
2 Answers
Generally you want to avoid publishing the virtual environment containing the installed dependencies for your project. The dependencies might not be cross-platform compatible.
Especially for projects that need to compile some C extensions generally each platform requires a separate binary ( or compilation).
It is more common to enumerate your dependencies in a requirements.txt
file. The requirements.txt
file should contain all the dependencies that are necessary to run your project.
In order not to publish your local venv
to git, two approaches are possible:
Keep your virtual environments in a location that is not inside the git root of your project
Add the virtual environment to the .gitignore file

- 16,943
- 7
- 52
- 69
Most projects I have seen usually put all the venv files in the .gitignore
, as, to my understanding, virtual environments are unique to each machine, so if you grab a venv in a specific computer, it won't work in another. Instead, each machine should have its own venv created locally.

- 602
- 1
- 6
- 26