python - 我正在尝试将我的 python 代码推送到 Heroku,但每次推送都失败
问题描述
我使用了命令git push heroku master
,这是输出错误:我认为这是 PostgreSQL 的问题。我相信 psycog2 的安装是阻止推送的原因,但我不确定如何修复它。任何人都对如何修复它有任何想法,我已经尝试通过更改 requirements.txt 来修复它
`Enumerating objects: 43, done.
Counting objects: 100% (43/43), done.
Delta compression using up to 2 threads
Compressing objects: 100% (39/39), done.
Writing objects: 100% (43/43), 1.53 MiB | 1.41 MiB/s, done.
Total 43 (delta 20), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.8.3
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting Flask==0.10.1
remote: Downloading Flask-0.10.1.tar.gz (544 kB)
remote: Collecting Flask-SQLAlchemy==2.1
remote: Downloading Flask-SQLAlchemy-2.1.tar.gz (95 kB)
remote: Collecting gunicorn==19.4.5
remote: Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112 kB)
remote: Collecting itsdangerous==0.24
remote: Downloading itsdangerous-0.24.tar.gz (46 kB)
remote: Collecting Jinja2==2.8
remote: Downloading Jinja2-2.8-py2.py3-none-any.whl (263 kB)
remote: Collecting MarkupSafe==0.23
remote: Downloading MarkupSafe-0.23.tar.gz (13 kB)
remote: Collecting psycopg2==2.6.1
remote: Downloading psycopg2-2.6.1.tar.gz (371 kB)
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4i9g6x68/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4i9g6x68/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-4i9g6x68/psycopg2/pip-egg-info
remote: cwd: /tmp/pip-install-4i9g6x68/psycopg2/
remote: Complete output (7 lines):
remote: running egg_info
remote: creating /tmp/pip-install-4i9g6x68/psycopg2/pip-egg-info/psycopg2.egg-info
remote: writing /tmp/pip-install-4i9g6x68/psycopg2/pip-egg-info/psycopg2.egg-info/PKG- INFO
remote: writing dependency_links to /tmp/pip-install-4i9g6x68/psycopg2/pip-egg- info/psycopg2.egg-info/dependency_links.txt
remote: writing top-level names to /tmp/pip-install-4i9g6x68/psycopg2/pip-egg- info/psycopg2.egg-info/top_level.txt
remote: writing manifest file '/tmp/pip-install-4i9g6x68/psycopg2/pip-egg- info/psycopg2.egg-info/SOURCES.txt'
remote: Error: could not determine PostgreSQL version from '12.3'
remote: ----------------------------------------
remote: ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to heightdata69.
remote:
To https://git.heroku.com/heightdata69.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/heightdata69.git'`
解决方案
从 psycopg 文档中,“为了从源代码、源分发包、GitHub 或 PyPI 安装 psycopg,必须满足构建先决条件。 ”
因此,要psycopg2
使用 pip 安装,您首先需要进行一些设置在这里。
psycopg2-binary==2.8.4
要修复该错误,您应该在文件中替换当前版本的 psycopg2,requirements.txt
而无需任何额外设置。
推荐阅读
- python - Python中正则表达式的每个位置的子字符串
- sql - 如何将日期转换为正确的格式并从中获得最大、最小范围?
- integration - Thingsboard中动态创建设备的访问令牌有什么用?
- android - 根据我的课程选择获取学院列表
- javascript - jsreport - Openlayers 未加载
- c# - 更新向导没有显示我在 db 中添加的列
- postgresql - PostgreSQL 11 中的逻辑复制和声明式分区
- python-3.x - pandas_profiling.ProfileReport 错误:ValueError:无法将浮点 NaN 转换为整数
- dialogflow-es - 如何使用 Dialoflow 发送电子邮件以执行 Google 操作
- ionic-framework - 如何在 ionic 4 中设置标题背景颜色