【问题标题】:Push to heroku fails推送到heroku失败
【发布时间】:2020-01-01 22:01:13
【问题描述】:

我正在按照本教程 https://www.codementor.io/jamesezechukwu/how-to-deploy-django-app-on-heroku-dtsee04d4 将我的 Django 应用程序部署到 heroku。这是我的第一个 Django 应用:

推送被拒绝,无法编译 Python 应用。

我目前正在运行 python 3.7.0。这是在我的 runtime.txt 文件中设置的: python-3.7.0

堆栈跟踪:

Enumerating objects: 11614, done.
Counting objects: 100% (11614/11614), done.
Delta compression using up to 4 threads
Compressing objects: 100% (8294/8294), done.
Writing objects: 100% (11614/11614), 42.09 MiB | 3.12 MiB/s, done.
Total 11614 (delta 2534), reused 8489 (delta 2166)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.7.3
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.7.0
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip



remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-build-r7xse4_1/django-dbbackup/setup.py", line 59, in <module>
remote:                install_requires=get_requirements(),
remote:              File "/tmp/pip-build-r7xse4_1/django-dbbackup/setup.py", line 45, in get_requirements
remote:                import pysftp  # @UnusedImport
remote:              File "/app/.heroku/python/lib/python3.7/site-packages/pysftp.py", line 10, in <module>
remote:                import paramiko
remote:              File "/app/.heroku/python/lib/python3.7/site-packages/paramiko/__init__.py", line 30, in <module>
remote:                from paramiko.transport import SecurityOptions, Transport
remote:              File "/app/.heroku/python/lib/python3.7/site-packages/paramiko/transport.py", line 61, in <module>
remote:                from paramiko.sftp_client import SFTPClient
remote:              File "/app/.heroku/python/lib/python3.7/site-packages/paramiko/sftp_client.py", line 41, in <module>
remote:                from paramiko.sftp_file import SFTPFile
remote:              File "/app/.heroku/python/lib/python3.7/site-packages/paramiko/sftp_file.py", line 66
remote:                self._close(async=True)
remote:                                ^
remote:            SyntaxError: invalid syntax
remote:            
remote:            ----------------------------------------
remote:        Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r7xse4_1/django-dbbackup/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-3pz1o34a-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-r7xse4_1/django-dbbackup/
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to {my_app}.
remote: 


 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/{my_app.git}'

需求txt文件:

asn1crypto==0.24.0
astroid==1.4.9
bcrypt==3.1.4
boto==2.34.0
boto3==1.9.38
botocore==1.12.104
cffi==1.11.5
coverage==4.5.1
cryptography==2.3.1
dj-database-url==0.3.0
dj-static==0.0.6
Django==2.2.4
django-dbbackup==2.0.4
django-filter==0.8
django-jsonfield==0.9.13
django-markdown-deux==1.0.5
django-oauth-plus==2.2.8
django-oauth2-provider==0.2.6.1
django-sslify==0.2.5
django-toolbelt==0.0.1
djangorestframework==2.4.4
djangorestframework-oauth==1.0.1
docutils==0.14
ecdsa==0.13
eventlog==0.11.0
gunicorn==19.1.1
httplib2==0.9
idna==2.7
isort==4.3.9
jmespath==0.9.4
lazy-object-proxy==1.3.1
Markdown==2.5.2
markdown2==2.3.0
mccabe==0.6.1
mock==2.0.0
newrelic==2.44.0.36
numpy==1.17.0
oauth2==1.9.0.post1
pandas==0.25.0
paramiko==1.15.2
pbr==5.1.2
pgeocode==0.1.1
psycopg2==2.7.5
py-mini-racer==0.1.15
pyasn1==0.4.4
pycparser==2.18
pycrypto==2.6.1
pylint==1.6.5
PyNaCl==1.2.1
pysftp==0.2.8
pystache==0.5.4
python-dateutil==2.8.0
pytz==2018.4
requests==2.2.1
requests-toolbelt==0.8.0
rsa==3.4.2
s3transfer==0.1.13
shortuuid==0.4.0
six==1.8.0
South==0.8.4
sqlparse==0.3.0
sqreen==1.13.3
static==1.1.1
static3==0.5.1
ua-parser==0.8.0
urllib3==1.24.1
user-agents==1.1.0
wh==1.2.0
whitenoise==1.0.6
wrapt==1.11.1
xkcdpass==1.2.5

有什么我错过的吗?我假设它是一个 python 3 问题

【问题讨论】:

    标签: python django python-3.x git heroku


    【解决方案1】:

    paramiko (1.15.2) 的版本与 python 3.7 不兼容。使用较新的版本。它使用async 关键字,该关键字在函数调用中保留为参数。

    如果您查看最新版本,您会发现 this particular line 的代码现在正在使用 async_

    您应该始终在本地计算机上使用与生产环境相同版本的 python,以便更早发现这些错误。

    我还建议您查看其他一些依赖项,您的 gunicorn 版本也超过 5 年,它包含安全漏洞,因此您正在使用的其他一些(旧)包可能会。

    最后,使用pip freeze 将本地virtualenv 中安装的内容与requirements.txt 进行比较。并确保它们是相同的!

    【讨论】:

    • 感谢您的回复,我可以将 requirements.txt 文件升级到新版本来解决问题吗?
    • 是的。但首先确保您在本地更改您的 virtualenv 以也使用 python 3.7 并在那里进行升级,您在要求中使用的 paramiko 版本是 5(!)岁,所以升级到最新版本可能会带来一些意外其他问题。
    • running 'python3 --version' 显示我的通风口正在运行 3.7.0。我已经升级了 paramiko 并提出了相应的问题(幸好只有 2 个其他要求需要升级!),但仍然得到相同的堆栈跟踪错误
    • 这是不可能的,最新版本 2.6.0 使用async_,因此如果您在需求文件中正确设置版本,它不会引发相同的错误。
    • 在我的虚拟环境中运行命令 -> python --version。返回 Python 3.7.0
    猜你喜欢
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多