Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why shouldn't I push a virtualenv to Heroku?

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?

like image 503
James Kelleher Avatar asked Apr 29 '15 22:04

James Kelleher


2 Answers

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.

like image 52
knbk Avatar answered Sep 28 '22 09:09

knbk


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

like image 35
Othman Avatar answered Sep 28 '22 08:09

Othman