【问题标题】:Heroku Django app deployment fails after trying to install python requirement尝试安装 python 要求后 Heroku Django 应用程序部署失败
【发布时间】:2021-04-26 12:38:01
【问题描述】:

我使用 pip install django-user-visit 安装了 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 并且根本不指定版本

【问题讨论】:

  • 您使用的是什么版本的 Python?你有runtime.txt吗?
  • pypi.org/project/django-user-visit 需要 Python >= 3.7。你需要在 Heroku 使用 Python 3.7+。
  • 谢谢 Chris 和博士,我想这是我的问题,Heroku 运行的是 3.6.12 而我的本地主机是 3.9,我将在我的 runtime.txt 文件中指定版本 3.7

标签: python django heroku pip


【解决方案1】:

来自文档:https://devcenter.heroku.com/articles/python-runtimes

如果您运行的 Python 应用程序需要不同的受支持运行时,或者如果您只是想在准备好升级之前锁定项目以防止补丁更新,您可以指定为您的应用使用哪个运行时。

要指定 Python 运行时,请将 runtime.txt 文件添加到应用的根目录,以声明要使用的确切版本号。

之后

pip freeze > requirements.txt

【讨论】:

    猜你喜欢
    • 2021-12-15
    • 2017-02-12
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    • 2017-12-17
    • 2015-02-28
    • 2018-08-21
    • 1970-01-01
    相关资源
    最近更新 更多