Tutorials online are telling me to put venv
in my .gitignore
file. Why wouldn't I want to push my virtual environment so that I or other developers could easily pull the project to their locals and conveniently have all dependencies?
On top of what Othman said, virtualenvs are simply not portable. Trying to move it will break it, and it's easier to create a new environment than to fix it. So, even on deployment platforms that do use virtual environments, checking them in to git is not going to work.
virtualenv is a tool to create isolated Python environments.
Heroku gives you one environment and you may install your packages using requirements.txt which is required by Heroku for Django applications.
If you want to share these dependencies with other developers use another remote to github. and push your requirements.txt
then tell your developers to install the packages using this file.
Example
requirements.txt
Django==1.3
Fabric==1.2.0
Jinja2==2.5.5
PyYAML==3.09
To install these packages in one time use:
pip install -r /path/to/requirements.txt
Moreover, when you run the application in your local machine then the virtual environment files might change, which will make push useless things to your repo.
Note: if you want to know which packages installed in your virtual environment then use pip freeze
If you want to export the packages to requirements.txt
then run
pip freeze > requirements.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With