找不到满足要求的版本pkg-resources==0.0.0。

66

我的应用程序部署在Heroku上。

当我通过git push heroku master提交代码时,它会给我这个错误。

Collecting pkg-resources==0.0.0 (from -r requirements.txt (line 14))
remote:          Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r requirements.txt (line 14)) (from versions: )
remote:        No matching distribution found for pkg-resources==0.0.0 (from -r requirements.txt (line 14))
remote:  !     Push rejected, failed to compile Python app.

requirement.txt

amqp==2.1.1
billiard==3.5.0.2
boto==2.42.0
celery==4.0.0
dj-database-url==0.4.1
Django==1.10.2
django-appconf==1.0.2
django-model-utils==2.6
django-storages==1.5.1
djangorestframework==3.4.7
gunicorn==19.6.0
Jinja2==2.8
kombu==4.0.0
MarkupSafe==0.23
optional-django==0.1.0
pep8==1.7.0
pkg-resources==0.0.0
psycopg2==2.6.2
pyflakes==1.3.0
pytz==2016.7
rcssmin==1.0.6
requests==2.12.1
rjsmin==1.0.12
vine==1.1.3
whitenoise==3.2.2

注意:在我的本地服务器上它完美无缺。

我的问题是为什么它在Heroku上不工作,但在本地上工作正常???


1
请在 requirement.txt 文件的第 14 行添加注释,并将代码推送。 - Afsal Salim
2
是的,它以前是可以工作的。但我想问一下为什么它在Heroku上不能工作呢? - Mahammad Adil Azeem
3
可能是 为什么pip freeze会列出“pkg-resources==0.0.0”? 的重复问题。 - Sayse
3
我明白这不是直接的副本,但我想是因为你的本地版本已经安装了它,因此不需要去寻找它。 - Sayse
你能在本地环境中展示 pip freeze 的输出吗? - demonno
显示剩余4条评论
5个回答

128

请从requirements.txt文件中删除以下行。

pkg-resources==0.0.0


32
为避免每次冻结时在requirements.txt文件中出现该内容,应使用以下命令从您的虚拟环境中删除它:pip uninstall pkg-resources==0.0.0

这是什么,为什么它首先出现了呢? - undefined

5

从 requirements.txt 中删除 pkg-resources==0.0.0

如果你希望下一次冻结的时候避免这个问题,使用 pip uninstall pkg-resources==0.0.0


1

cat requirements.txt | grep --invert-match pkg-resources | xargs -n 1 pip install

这行命令是用来安装Python依赖包的。它从requirements.txt文件中读取依赖列表,然后使用pip命令进行安装。其中grep和xargs命令用于过滤掉名为pkg-resources的依赖项。如果你想了解更详细的信息,请参考以下链接: https://code-specialist.com/python/pkg-resources


1
目前你的回答不够清晰,请编辑并添加更多细节,以帮助其他人理解它如何回答问题。你可以在帮助中心找到有关如何编写好答案的更多信息。 - Community

0

看起来 Heroku CLI 正在使用来自不同本地分支的依赖项。 如果您正在运行:

$ git push origin master

要在Heroku上部署您的应用程序,请确保在本地切换到主分支。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接