我正试图将django项目部署到heroku,但我遇到了这个错误。
错误:命令出错,退出状态为1:/app/.horoku/python/bin/python/app/.horoku-python/lib/python3.8/site-packages/pip/vendor/pep517/in_process.py prepare_metadata_for_build_wheel/tmp/tmp5mrz1adn检查日志以获取完整的命令输出。!推送被拒绝,无法编译Python应用程序。!推送失败的
这是整个日志
ctivity Feed Build LogID 314cb820-4652-417b-9486-61d629e4a6a9
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
-----> Installing python-3.8.12
-----> Installing pip 20.2.4, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting alembic==1.6.5
Downloading alembic-1.6.5-py2.py3-none-any.whl (164 kB)
Collecting asgiref==3.3.4
Downloading asgiref-3.3.4-py3-none-any.whl (22 kB)
Collecting Babel==2.9.1
Downloading Babel-2.9.1-py2.py3-none-any.whl (8.8 MB)
Collecting bcrypt==3.2.0
Downloading bcrypt-3.2.0-cp36-abi3-manylinux2010_x86_64.whl (63 kB)
Collecting bidict==0.21.2
Downloading bidict-0.21.2-py2.py3-none-any.whl (37 kB)
Collecting blinker==1.4
Downloading blinker-1.4.tar.gz (111 kB)
Collecting Brotli==1.0.9
Downloading Brotli-1.0.9-cp38-cp38-manylinux1_x86_64.whl (357 kB)
Collecting cffi==1.14.6
Downloading cffi-1.14.6-cp38-cp38-manylinux1_x86_64.whl (411 kB)
Collecting cheroot==8.5.2
Downloading cheroot-8.5.2-py2.py3-none-any.whl (97 kB)
Collecting click==7.1.2
Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting cryptography==3.4.7
Downloading cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)
Collecting Django==3.2.8
Downloading Django-3.2.8-py3-none-any.whl (7.9 MB)
Collecting django-ckeditor==6.1.0
Downloading django_ckeditor-6.1.0-py2.py3-none-any.whl (2.4 MB)
Collecting django-filter==2.4.0
Downloading django_filter-2.4.0-py3-none-any.whl (73 kB)
Collecting django-js-asset==1.2.2
Downloading django_js_asset-1.2.2-py2.py3-none-any.whl (5.8 kB)
Collecting django-multiselectfield==0.1.12
Downloading django_multiselectfield-0.1.12-py3-none-any.whl (15 kB)
Collecting dnspython==1.16.0
Downloading dnspython-1.16.0-py2.py3-none-any.whl (188 kB)
Collecting email-validator==1.1.3
Downloading email_validator-1.1.3-py2.py3-none-any.whl (18 kB)
Collecting eventlet==0.31.0
Downloading eventlet-0.31.0-py2.py3-none-any.whl (224 kB)
Collecting Flask==1.1.4
Downloading Flask-1.1.4-py2.py3-none-any.whl (94 kB)
Collecting Flask-BabelEx==0.9.4
Downloading Flask_BabelEx-0.9.4-py3-none-any.whl (8.7 kB)
Collecting Flask-Compress==1.10.1
Downloading Flask_Compress-1.10.1-py3-none-any.whl (7.9 kB)
Collecting Flask-Gravatar==0.5.0
Downloading Flask_Gravatar-0.5.0-py2.py3-none-any.whl (7.5 kB)
Collecting Flask-Login==0.5.0
Downloading Flask_Login-0.5.0-py2.py3-none-any.whl (16 kB)
Collecting Flask-Mail==0.9.1
Downloading Flask-Mail-0.9.1.tar.gz (45 kB)
Collecting Flask-Migrate==2.7.0
Downloading Flask_Migrate-2.7.0-py2.py3-none-any.whl (13 kB)
Collecting Flask-Paranoid==0.2.0
Downloading Flask_Paranoid-0.2.0-py2.py3-none-any.whl (4.1 kB)
Collecting Flask-Principal==0.4.0
Downloading Flask-Principal-0.4.0.tar.gz (5.5 kB)
Collecting Flask-Security-Too==4.0.1
Downloading Flask_Security_Too-4.0.1-py2.py3-none-any.whl (244 kB)
Collecting Flask-SocketIO==5.1.0
Downloading Flask_SocketIO-5.1.0-py2.py3-none-any.whl (16 kB)
Collecting Flask-SQLAlchemy==2.5.1
Downloading Flask_SQLAlchemy-2.5.1-py2.py3-none-any.whl (17 kB)
Collecting Flask-WTF==0.15.1
Downloading Flask_WTF-0.15.1-py2.py3-none-any.whl (13 kB)
Collecting greenlet==1.1.0
Downloading greenlet-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (164 kB)
Collecting gunicorn==20.1.0
Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
Collecting httpagentparser==1.9.1
Downloading httpagentparser-1.9.1.tar.gz (7.9 kB)
Collecting idna==3.2
Downloading idna-3.2-py3-none-any.whl (59 kB)
Collecting importlib-resources==5.2.2
Downloading importlib_resources-5.2.2-py3-none-any.whl (27 kB)
Collecting itsdangerous==1.1.0
Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting jaraco.functools==3.3.0
Downloading jaraco.functools-3.3.0-py3-none-any.whl (6.8 kB)
Collecting Jinja2==2.11.3
Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
Collecting ldap3==2.9
Downloading ldap3-2.9-py2.py3-none-any.whl (430 kB)
Collecting Mako==1.1.4
Downloading Mako-1.1.4-py2.py3-none-any.whl (75 kB)
Collecting MarkupSafe==2.0.1
Downloading MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
Collecting more-itertools==8.8.0
Downloading more_itertools-8.8.0-py3-none-any.whl (48 kB)
Collecting paramiko==2.7.2
Downloading paramiko-2.7.2-py2.py3-none-any.whl (206 kB)
Collecting passlib==1.7.4
Downloading passlib-1.7.4-py2.py3-none-any.whl (525 kB)
Collecting pgadmin4==5.4
Downloading pgadmin4-5.4-py3-none-any.whl (99.6 MB)
Collecting Pillow==8.3.1
Downloading Pillow-8.3.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.0 MB)
Collecting postgres==4.0
Downloading postgres-4.0-py2.py3-none-any.whl (21 kB)
Collecting psutil==5.8.0
Downloading psutil-5.8.0-cp38-cp38-manylinux2010_x86_64.whl (296 kB)
Collecting psycopg2==2.9.1
Downloading psycopg2-2.9.1.tar.gz (379 kB)
Collecting psycopg2-binary==2.8.6
Downloading psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
Collecting psycopg2-pool==1.1
Downloading psycopg2_pool-1.1-py2.py3-none-any.whl (7.3 kB)
Collecting pyasn1==0.4.8
Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting pycparser==2.20
Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting PyNaCl==1.4.0
Downloading PyNaCl-1.4.0-cp35-abi3-manylinux1_x86_64.whl (961 kB)
Collecting python-dateutil==2.8.1
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting python-editor==1.0.4
Downloading python_editor-1.0.4-py3-none-any.whl (4.9 kB)
Collecting python-engineio==4.2.0
Downloading python_engineio-4.2.0-py2.py3-none-any.whl (51 kB)
Collecting python-socketio==5.3.0
Downloading python_socketio-5.3.0-py2.py3-none-any.whl (53 kB)
Collecting pytz==2021.1
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting pywinpty==1.1.1
Downloading pywinpty-1.1.1.tar.gz (48 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python /app/.heroku/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp5mrz1adn
cwd: /tmp/pip-install-19xig8s3/pywinpty
Complete output (6 lines):
Checking for Rust toolchain...
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
----------------------------------------
ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python /app/.heroku/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp5mrz1adn Check the logs for full command output.
! Push rejected, failed to compile Python app.
! Push failed
myruntime.txt包含heroku支持的python 3.8.12版本。
请建议我应该如何解决此错误。
仔细阅读日志文件后,以下是我建议的干净部署方法。
当venv被激活并且您在项目目录(manage.py
所在的目录)中时,执行以下操作:
- 打开requirements.txt
- 从requirements.txt中删除不需要的模块
- 使用
pip uninstall module
卸载不需要的模块 - 现在运行
pip freeze requirements.txt
- 停用venv
- 然后将
requirements.txt
添加到源代码管理git add -A
- 提交更改
git commit -m "deleted unneeded modules"
- 如果你已经存在Heroku应用程序,请使用连接到它
heroku git:remote -a myapp
,否则通过此步骤 - 部署,
git push heroku master
如果你不确定你的项目需要哪些模块,而我不能确切地确定项目的需求,但如果你有基本项目,你只需要3个模块,即Django
、psycopg2-binary
、gunicorn
,那么请执行以下操作进行干净部署:
- 删除供应商
- 在项目目录之外,创建新目录
- 激活venv
- 安装您需要的模块,可能是
Django
、psycopg2-binary
、gunicorn
- 现在运行
pip freeze requirements.txt
- 停用venv
- 然后将
requirements.txt
添加到源代码管理git add -A
- 提交您的更改
git commit -m "deleted unneeded modules"
- 如果你已经存在Heroku应用程序,请使用连接到它
heroku git:remote -a myapp
,否则通过此步骤 - 部署,
git push heroku master