foobar_98
foobar_98

Reputation: 127

What do I add to my requirements.txt in Django directory in order to push it to Heroku?

I am new to programming/web development and I want to push a Django directory to heroku. But every time I enter "git push heroku master" into my command line I get the same error:

"Could not find a version that satisfies the requirement bonjour-py==0.3 (from -r /tmp/build_602f#############86ff270e/requirements.txt (line 3)) (from versions: )"

I activated the virtual environment, but to no avail. Now I assume that the problem might be that my requirements.txt file does not contain anything (as I thought there would not be a reason for that, anyway). Still, I wonder what "bonjour-py==0.3" is and how that could be fixed. Thank you very much for your help!

Upvotes: 5

Views: 16202

Answers (2)

Tobi Klostermair
Tobi Klostermair

Reputation: 205

The problem is, that python2.7 and python3.x are different versions. You need the same version of python - server and local.

ToDos:

  1. Take the terminal an go to the project directory

    cd /your/path/to/project/

  2. Activate your virtualenv

    source env/bin/activate

  3. Generate requirements.txt with pip

    pip freeze > requirements.txt

  4. Go to your server and create new virtualenv with same python version (https://virtualenv.pypa.io/en/stable/reference/#cmdoption-p)

    virtualenv --python=python2.7 env

  5. Activate virtualenv on server

    source env/bin/activate

  6. Install requirements.txt with pip

    pip install -r requirements.txt

  7. Django migrations

    python manage.py migrate

  8. Start django with runserver (to test) or connect webserver (nginx, uwsgi, gunicorn, ...)

    python manage.py runserver

Upvotes: 7

Kostas Livieratos
Kostas Livieratos

Reputation: 1067

Inside your Python virtual environment and in your project path, just type:

pip freeze > requirements.txt.

This will list inside the requirements.txt file the exact version of each python package you use. And that's how Heroku will know what packages it needs to install in order to run your Django app.

Upvotes: 12

Related Questions