python - 尝试安装 python 要求后 Heroku Django 应用程序部署失败
问题描述
我安装了 django-user-visit pip install django-user-visit
,在本地环境中对其进行了测试,一切似乎都运行良好,但是当我尝试使用Heroku将我的应用程序部署到生产环境时,我收到以下错误:
remote: Collecting django-cors-headers==3.6.0
remote: Downloading django_cors_headers-3.6.0-py3-none-any.whl (12 kB)
remote: ERROR: Could not find a version that satisfies the requirement django-user-visit==0.4.1 (from -r /tmp/build_940d12d0/requirements.txt (line 4)) (from versions: none)
remote: ERROR: _No matching distribution_ found for django-user-visit==0.4.1 (from -r /tmp/build_940d12d0/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
有谁知道为什么 Heroku 找不到包裹,如果我能解决这个问题?
通过运行我的requirements.txt
文件中指示的库来安装我的包:
asgiref==3.3.1
Django==3.1.5
django-cors-headers==3.6.0
django-user-visit==0.4.1
djangorestframework==3.12.2
gunicorn==20.0.4
psycopg2==2.8.6
pytz==2020.5
sqlparse==0.4.1
ua-parser==0.10.0
user-agents==2.2.0
whitenoise==5.2.0
到目前为止我尝试的是将版本更改为 0.4 并且根本不指定版本
解决方案
来自文档:https ://devcenter.heroku.com/articles/python-runtimes
如果您正在运行需要不同支持的运行时的 Python 应用程序,或者如果您只是想在准备好升级之前锁定项目以防止补丁更新,您可以指定要用于您的应用程序的运行时。
要指定 Python 运行时,请将runtime.txt
文件添加到应用程序的根目录,该文件声明要使用的确切版本号。
在那之后
pip freeze > requirements.txt
推荐阅读
- node.js - 模块上下文中提供了如何修复索引 [0] 处的 AXIOS_INSTANCE_TOKEN
- ios - 如何使用加速度计数据 Swift 确定运动?
- c++ - 警告 C4715:并非所有控制路径都返回值 c++ - 无法通过测试
- azure-databricks - 为什么 Azure Databricks 需要将数据存储在 Azure 的临时存储中
- reactjs - 何时在 React 应用程序中的组件和页面之间使用导航与“基于状态的切换”?
- apache-kafka - 使用 Kafka-Streams 进行重复数据删除
- ramda.js - 使用从 ramda 中的原始属性派生的新属性转换对象
- reactjs - 如何从 Firebase Firestore 快照(React Hooks)中获取对象?
- c# - 如何告诉 Blazor Webassembly 网站的访问者他们的浏览器不支持 Webassembly?
- angular - 如果服务器是 Spring,如何在 Angular 中渲染?