我正在尝试将python代码推送到Heroku,但每次推送都会失败

时间:2020-06-25 19:15:49

标签: 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'`

1 个答案:

答案 0 :(得分:0)

从psycopg文档中,“ 要满足构建先决条件,以便从源代码,源分发包,GitHub或PyPI安装psycopg。
因此,要使用pip安装psycopg2,您首先需要进行一些here的设置。

要解决该错误,您应该在psycopg2-binary==2.8.4文件中用requirements.txt替换当前版本的psycopg2,而无需进行任何其他设置。