【问题标题】:Manually remove Python package on Heroku在 Heroku 上手动删除 Python 包
【发布时间】:2013-02-09 09:08:56
【问题描述】:

我在运行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

【问题讨论】:

  • 您的requirements.txt 中如何指定Django?您是在告诉它使用特定版本吗?
  • 请看上面的更新。
  • @metroxylon 检查当您推送更改时您的测功机会发生什么heroku logs -t。尝试从需求中删除Django==1.5,提交,推送到heroku,然后使用django添加并提交。
  • 当您从 pypi 安装切换到 github 时,Heroku 无法识别更改。它不会在 pypi 版本上安装 github 版本。

标签: django deployment heroku installation


【解决方案1】:

将当前的 virtenv 包推送到文件

pip freeze > requirements.txt

提交

git commit -am 'update packages'

然后推送到heroku

git push heroku

然后heroku会重建环境

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

【讨论】:

  • 这是我做的(除了外部的鸡蛋)。将使用我的 requirements.txt 进行更新
【解决方案2】:

我遇到了 Heroku 缓存损坏的包并且无法将其取出的问题。 Python buildpack 应该支持刷新此缓存 (CACHE_DIR),但它没有。

有一个解决方法:按照these instructions 将您的 Python 运行时更改为例如 3.3.0(无论您的应用是否真的支持 Python 3 都没有关系)。然后将其更改回默认值。更改 Python 运行时然后部署的行为将强制 buildpack 完全擦除缓存。据我所知,这是目前清除缓存的唯一实用方法。

【讨论】:

  • 这解决了我的问题。我尝试手动运行heroku run pip uninstall my_package,它“工作”(没有失败)但包仍在系统中并导致我出现问题。感谢您的提示!
  • 是的,直到今天仍然有效。更改(或第一次添加)runtime.txt 然后重新部署会导致 Heroku 创建一个新的运行时环境,从而有效地消除任何遗留问题,例如拒绝使用相同包的不同版本覆盖 PYPI 中先前安装的包来自 github 网址。
  • 对我不起作用...我的意思是,当我将运行时更改为不同版本的 python 时,它确实如此,但是当我将其更改回我真正想要使用的版本时,它使用了旧缓存。
  • @Micah 我正要愤怒地跺我的笔记本电脑,遇到同样的问题,直到我读到你的评论,tks
  • 我遇到了 Heroku 的问题,抱怨找不到 psycpg2 包,这解决了。谢谢!
【解决方案3】:

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

【讨论】:

    猜你喜欢
    • 2013-11-11
    • 1970-01-01
    • 2017-12-15
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2020-01-14
    • 2014-12-05
    相关资源
    最近更新 更多