Heroku关于requirements.txt中setuptools/distribute的警告信息

0 投票
2 回答
941 浏览
提问于 2025-04-18 16:17

我在把一个Python应用程序上传到Heroku时,遇到了这个问题:

!     The package setuptools/distribute is listed in requirements.txt.
!     Please remove to ensure expected behavior.

文档里明确要求在requirements.txt文件中包含distribute这个库,当我把它删掉后,就出现了这个错误(看起来确实是依赖于distribute的):

Traceback (most recent call last):
  File "/app/.heroku/python/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

 !     Push rejected, failed to compile Python app

2 个回答

1

升级一下 setuptoolsdistribute 这两个工具。

pip install --upgrade setuptools
pip install --upgrade distribute

更新你的 requirements.txt 文件。这个方法昨天对我来说正好有效。

2

这个问题虽然很老了,但如果你碰巧看到这个并且还在寻找答案,可以试试升级你的Heroku构建包(就是一系列用来在Heroku服务器上构建你应用的脚本)。这样做会更新pip(还有其他一些东西),因为你不能完全按照Mauro的建议来做,因为代码是要部署到Heroku的服务器上的。

关于构建包的更多信息,可以查看这个链接: https://devcenter.heroku.com/articles/buildpacks

不过如果你不想看文章,直接输入下面的命令就行:

$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python

然后像往常一样重新尝试部署你的应用。

撰写回答