将git库推送到heroku时失败,并给出以下错误:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the same version as the last build: python-3.9.7
remote: To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Requirements file has been changed, clearing cached dependencies
remote: -----> Installing python-3.9.7
remote: -----> Installing pip 20.2.4, setuptools 57.5.0 and wheel 0.37.0
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting Gunicorn==20.1.0
remote: Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
remote: Collecting Jinja2==2.11.2
remote: Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
remote: Collecting Django-Heroku==0.3.1
remote: Downloading django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
remote: ERROR: Could not find a version that satisfies the requirement Django-3.2.8 (from -r /tmp/build_43fa9180/requirements.txt (line 4)) (from versions: none)
remote: ERROR: No matching distribution found for Django-3.2.8 (from -r /tmp/build_43fa9180/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 262a4549043aa448dc2000c886cad672f979d8f0
remote: !
remote: ! We have detected that you have triggered a build from source code with version 262a4549043aa448dc2000c886cad672f979d8f0
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to shrouded-bastion-04661.
remote:
To https://git.heroku.com/shrouded-bastion-04661.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shrouded-bastion-04661.git'
使用python 3.9.7,与django 3.2.8兼容。奇怪的是,一切都很好,直到我遵循这个教程使用Azure托管静态文件https://medium.com/@DawlysD/django-using- Azure -blob-storage-to- handling -static-media-assets-from-scratch-90cbbc7d56be
从那以后,我不得不安装PostgreSQL和Visual Studio,只是为了让pg_config文件工作。
编辑:下面是requirements.txt:
Gunicorn==20.1.0
Jinja2==2.11.2
Django-Heroku==0.3.1
Django-3.2.8
asgiref-3.4.1
azure-core-1.19.0
azure-storage-blob-12.9.0
certifi-2021.10.8
cffi-1.15.0
charset-normalizer-2.0.7
cryptography-35.0.0
django-storages-1.12.2
idna-3.3
isodate-0.6.0
msrest-0.6.21
oauthlib-3.1.1
pycparser-2.20
pytz-2021.3
requests-2.26.0
requests-oauthlib-1.3.0
six-1.16.0
sqlparse-0.4.2
urllib3-1.26.7
-
在版本说明符中无效。
格式为package-version
的所有依赖项需要更改为package==version
。
例如,修改
Django-3.2.8
Django==3.2.8
和
azure-storage-blob-12.9.0
azure-storage-blob==12.9.0