python - 将 python 烧瓶应用程序上传到 Heroku 会引发错误
问题描述
在将我的 python 烧瓶应用程序上传到 Heroku 时,出现以下错误:
ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from -r /tmp/build_d980c139/requirements.txt (line 4)) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
remote: ERROR: No matching distribution found for dataclasses==0.8 (from -r /tmp/build_d980c139/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
解决方案
Heroku 为您的应用程序安装最新的 python 版本。目前我假设它正在安装 python 版本 3.9.6。但是从 python 3.8.0 起,dataclasses==0.8 是在那里预先构建的。此外部数据类库仅存在于 0.1 - 0.6 版本(显示在错误消息中),并且可能已停止升级,因为它现在在预构建中退出。由于它没有找到那个特定的 0.8 版本,所以它抛出了那个未找到的错误。
现在要解决这个问题,有两种方法 - 简单的方法是从 requirements.txt 中删除 dataclasses==0.8 并上传。
另一种方法是将 dataclasses==0.8 保留在 requirements.txt 中,并在您的 requirements.txt 所在的同一根目录中添加另一个名为“runtime.txt”的 txt 文件。而这条线 - Python {yourspecifiedversion}
。这将告诉 Heroku 要安装哪个 python 版本。您可以选择与所有外部库正确匹配的 python 版本。但如果 python 版本低于 3.8.0,则需要添加 'dataclasses==0.8'
在此链接中指定 Heroku 上的 python 运行时 -指定 Python 运行时
推荐阅读
- python - 在 for 循环中更改循环字符串
- java - 如何将 InputStream 字节写入字符串?
- reactjs - 有人知道如何立即重定向到链接吗?反应
- angular - Angular:将公共环境变量分开到 commonEnv.ts 文件
- php - 如何在测试开始之前调用 php artisan dictionary:schema:update?PhpUnit
- java - 如何使用 JNA (Java) 为活动窗口获取 X11 WM_CLASS?
- java - Apache Pulsar,无法从 getCounter() 读取值,但可以读取其他状态值
- sql - 从 T-SQL 生成带有 INSERT SELECT 语句的脚本
- python - 按子键按字母顺序对嵌套字典进行排序
- mysql - 连接到节点 js 服务器时出现错误(angularjs、nodejs、mysql 连接)