8

I was running heroku push master, and got this:

 ----- Python app detected
 ----- No runtime.txt provided; assuming python-2.7.3.
 ----- Using Python runtime (python-2.7.3)
 ----- Installing dependencies using Pip (1.2.1)
        Downloading/unpacking Django-1.5c2 from https://www.djangoproject.com/download/1.5c2/tarball (from -r
                                                                                                             requirements.txt (line 1))
          Cannot determine compression type for file /tmp/pip-rYIGHS-unpack/tarball.ksh
          Running setup.py egg_info for package Django-1.5c2

        Installing collected packages: Django-1.5c2
          Running setup.py install for Django-1.5c2
            changing mode of build/scripts-2.7/django-admin.py from 600 to 755

            changing mode of /app/.heroku/python/bin/django-admin.py to 755


            ========
            WARNING!
            ========

            You have just installed Django over top of an existing
            installation, without removing it first. Because of this,
            your install may now include extraneous files from a
            previous version that have since been removed from
            Django. This is known to cause a variety of problems. You
            should manually remove the

            /app/.heroku/python/lib/python2.7/site-packages/django

            directory and re-install Django.

        Successfully installed Django-1.5c2

How can I remove the previous Django package?

UPDATE: My requirements.txt:

https://www.djangoproject.com/download/1.5c2/tarball/**#egg=django**
South==0.7.6
argparse==1.2.1
distribute==0.6.24
dj-database-url==0.2.1
psycopg2==2.4.6
wsgiref==0.1.2
PIL==1.1.7

The text in bold fixed the above warning.

UPDATE 2: Since Django 1.5 was officially released, I just used pip freeze:

Django==1.5
South==0.7.6
argparse==1.2.1
distribute==0.6.24
dj-database-url==0.2.1
psycopg2==2.4.6
wsgiref==0.1.2
PIL==1.1.7
blaze
  • 2,588
  • 3
  • 32
  • 47
  • How is Django specified in your `requirements.txt`? Are you telling it to use a particular version? – culix Feb 25 '13 at 03:27
  • Please see the update above. – blaze Feb 28 '13 at 22:45
  • @metroxylon Check what happens with your dyno when you push changes `heroku logs -t`. Try to delete `Django==1.5` from requirement, commit, push to heroku, then add and commit with django. – b1_ Mar 01 '13 at 07:27
  • Heroku doesn't recognize the change when you switch from a pypi install to a github. it won't install the github version over the pypi version. – B Robster Feb 09 '14 at 05:10

3 Answers3

20

I've had problems where Heroku caches broken packages and there's no way to get them out. The Python buildpack should have some kind of support for flushing this cache (CACHE_DIR), but it does not.

There is a workaround: follow these instructions to change your Python runtime to, for instance, 3.3.0 (it doesn't matter if your app actually supports Python 3 or not). Then change it back to the default. The act of changing your Python runtime and then deploying will force the buildpack to totally erase the cache. As far as I know this is the only practical way to erase the cache at the moment.

Andrew Gorcester
  • 19,595
  • 7
  • 57
  • 73
  • 1
    This fixed the problem for me. I tried manually running `heroku run pip uninstall my_package` which "worked" (didn't fail) but the package was still in the system and causing me problems. Thanks for the tip! – Micah Nov 27 '13 at 13:08
  • Yep, still works as of today. Changing (or adding for the first time) runtime.txt and then re-deploying causes Heroku to create a fresh runtime environment, effectively destroying any legacy issues such as the refusal to overwrite previously installed packages from PYPI with a different version of the same package from a github url. – B Robster Feb 09 '14 at 05:16
  • Doesn't work for me... I mean, it did when I changed the runtime to a different version of python, but when I then changed it back to the one I actually wanted to use, it used the old cache. – Phil Gyford Jul 07 '16 at 17:13
  • @Micah I was about to rage stomp my laptop having the same problem untill i read your comment, tks – wolfgang Jun 02 '17 at 07:58
  • I had a problem with heroku complaining that psycpg2 package wasn't found, this solved it. Thank you! – Alexander Aug 02 '21 at 17:54
3

Push current virtenv package to file

pip freeze > requirements.txt

Commit

git commit -am 'update packages'

And push to heroku

git push heroku

Then heroku will rebuild the environment

Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (13/13), 1.26 KiB, done.
Total 13 (delta 3), reused 0 (delta 0)
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.3.
-----> Preparing Python runtime (python-2.7.3)
-----> Installing Distribute (0.6.34)
-----> Installing Pip (1.2.1)
-----> Installing dependencies using Pip (1.2.1)
Downloading/unpacking Flask==0.9 (from -r requirements.txt (line 1))
Running setup.py egg_info for package Flask
devinho
  • 404
  • 4
  • 18
b1_
  • 2,069
  • 1
  • 27
  • 39
  • This is what a I did (except for the external egg). Will update with my requirements.txt – blaze Feb 28 '13 at 22:40
0

Thought I removed the faulting package and all other packages that depends on it but nope. Each time I deploy I keep getting an error. Finally I somehow striped out all other packages that depends on the faulting package and everything worked perfectly. Hope somebody will find this useful

shellking4
  • 109
  • 3
  • 12