在Heroku上手动删除Python包

时间:2013-02-23 22:15:49

标签: django deployment heroku installation

我正在运行heroku push master,并得到了这个:

 ----- 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

如何删除以前的Django包?

更新: 我的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

粗体文字修正了上述警告。

更新2: 自从Django 1.5正式发布以来,我只是使用了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

3 个答案:

答案 0 :(得分:16)

我遇到了Heroku缓存破坏包裹的问题,而且没有办法让它们失效。 Python buildpack应该有一些支持来刷新这个缓存(CACHE_DIR),但事实并非如此。

有一种解决方法:按照these instructions将Python运行时更改为例如3.3.0(如果您的应用程序实际上支持Python 3,则无关紧要)。然后将其更改回默认值。更改Python运行时然后部署的操作将强制buildpack完全擦除缓存。据我所知,这是目前擦除缓存的唯一实用方法。

答案 1 :(得分:0)

将当前的virtenv包推送到文件

pip freeze > requirements.txt

提交

git commit -am 'update packages'

推送到heroku

git push heroku

并且herocu重建环境

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

答案 2 :(得分:0)

我以为我删除了有问题的包和所有其他依赖它的包,但没有。每次部署时,我都会收到错误消息。最后,我以某种方式删除了依赖于故障包的所有其他包,并且一切正常。希望有人会觉得这很有用