martes, 4 de octubre de 2011

Heroku push rejected, failed to compile Python/django app

       

You might have seen this error when trying to push to heroku your django app using pip:

Running setup.py install for distribute
           Before install bootstrap.
           Scanning installed packages
           Setuptools installation detected at /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
           Egg installation
           Patching...
           Renaming /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg into /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1317780660.95
           Patched done.
           Relaunching...
           Traceback (most recent call last):
             File "<string>", line 1, in <module>
           NameError: name 'install' is not defined
           Complete output from command /tmp/build_2pim0d1o5mgy0/bin/python2.7 -c "import setuptools;__file__='/tmp/build_2pim0d1o5mgy0/build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-UtGheN-record/install-record.txt --install-headers /tmp/build_2pim0d1o5mgy0/include/site/python2.7:
           Before install bootstrap.
      
       Scanning installed packages
      
       Setuptools installation detected at /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
      
       Egg installation
      
       Patching...
      
       Renaming /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg into /tmp/build_2pim0d1o5mgy0/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1317780660.95
      
       Patched done.
      
       Relaunching...
      
       Traceback (most recent call last):
      
         File "<string>", line 1, in <module>
      
       NameError: name 'install' is not defined
      
       ----------------------------------------
       Command /tmp/build_2pim0d1o5mgy0/bin/python2.7 -c "import setuptools;__file__='/tmp/build_2pim0d1o5mgy0/build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-UtGheN-record/install-record.txt --install-headers /tmp/build_2pim0d1o5mgy0/include/site/python2.7 failed with error code 1
       Storing complete log in /app/.pip/pip.log
 !     Heroku push rejected, failed to compile Python/django app

The problem is the distribute package, open requirements.txt and delete that line.
It should work now.

UPDATE:
The problem is that my distribute was too old so the real solution is to
pip install distribute -U
To upgrade it, don't forget to also update your requirements.txt
pip freeze > requirements.txt