在 Heroku 上加载应用程序依赖项时出现问题

Problem loading application dependencies on Heroku

我正在尝试将程序部署到 Heroku,但是在安装多个依赖项时出现错误:

'No matching distribution found for random'

也适用于 timepickle 依赖项。在网上查到是没有更新导致的,但是没有找到解决办法。 文件内容requirements.txt:

telebot
config
random
datetime
pickle
time

文件内容Procfile.windows:

bot: python3 bot.py

与许多语言一样,Python 附带了一个 standard library,其中包含一定数量的开箱即用的基本功能。 requirements.txt 文件中的大多数依赖项都包含在此标准库中。不需要自己安装。

删除 random, datetime, pickle, and time from that file. You should be able to import and use them automatically. telebot and config 不是标准库的一部分,所以它们应该保留:

telebot
config

您的 requirements.txt 应该可以在本地和 Heroku 上运行。您可以通过 运行 pip install -r requirements.txt.

将它的依赖项安装到您当前的环境中

此外,您的 Procfile 可能需要更改。在不了解您的项目的情况下,我不能肯定地说,但您的流程类型可能应该是 web,并且您可能需要使用 python 而不是 python3(尽管 python3 也可能有效):

web: python bot.py

文件应名为 Procfile,不带任何文件扩展名。