Changing package install order in Python
Question: Does anyone know if package install order matters in Python? More specifically
my pip `requirements.txt` for a Django website I am building was:

    
    
    Django==1.4
    MySQL-python==1.2.3
    django-evolution==0.6.7
    django-pagination==1.0.7
    boto==2.5.2
    numpy==1.6.2
    requests==0.13.1
    simplejson==2.5.2
    gunicorn==0.14.6
    

When deploying to Heroku the application would crash with the following error:

    
    
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [12] [INFO] Worker exiting (pid: 12)
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [8] [INFO] Worker exiting (pid: 8)
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Handling signal: term
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [7] [INFO] Worker exiting (pid: 7)
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Starting gunicorn 0.14.6
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Listening at: http://0.0.0.0:20132 (4)
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Using worker: sync
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [7] [INFO] Booting worker with pid: 7
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [8] [INFO] Booting worker with pid: 8
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [9] [INFO] Booting worker with pid: 9
    2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [10] [INFO] Booting worker with pid: 10
    2012-08-05T09:26:57+00:00 heroku[web.1]: State changed from starting to up
    2012-08-05T09:26:57+00:00 heroku[web.1]: Process exited with status 143
    2012-08-05T09:27:17+00:00 app[web.1]: Usage: gunicorn [options]
    2012-08-05T09:27:17+00:00 app[web.1]: gunicorn: error: no such option: --workers
    2012-08-05T09:27:17+00:00 app[web.1]: 
    2012-08-05T09:27:17+00:00 app[web.1]: 2012-08-05 09:27:17 [9] [INFO] Worker exiting (pid: 9)
    

Where my `Procfile` is as follows:

    
    
    web: python manage.py collectstatic --noinput; gunicorn commerical_production.wsgi:application --workers=4 --bind=0.0.0.0:$PORT
    

The problem was fixed by simply changing the order of requirements to:

    
    
    Django==1.4
    gunicorn==0.14.6
    MySQL-python==1.2.3
    django-evolution==0.6.7
    django-pagination==1.0.7
    boto==2.5.2
    numpy==1.6.2
    requests==0.13.1
    simplejson==2.5.2
    

(note that `gunicorn` is now moved to the top)

I found this out by luckily guessing to try and change the order of the
imports but my question is has anyone else run into this problem or know why
the order of the packages makes a difference when installed from the
`requirements.txt`? Could this problem indicative of some larger dependency
issue that is in my app?


Answer: Pip is not very good at handling package dependencies as easy_install. We had
the same problem in our project. Even though the order in req.txt was correct,
we had dependency problems that is related to order.

My solution is to feed the req.txt to easy_install, but than you should be
careful with the packages that is editable or those from github etc.

You may want to check below links:

<http://metak4ml.blogspot.com/2009/08/easyinstall-read-pip-
requirementstxt.html> http://community.webfaction.com/questions/1220/using-
easy_install-to-get-all-dependencies-listed-in-requirementstxt (while read
line answer is close to what we do)

