简体   繁体   English

Heroku 无法安装 psycopg2

[英]Heroku fails to install psycopg2

I am trying to get Heroku to install psycopg2 from requirements.txt, which contains:我试图让 Heroku 从 requirements.txt 安装 psycopg2,其中包含:

falcon
gunicorn>=19.6.0
gevent>=0.13
ujson
SQLAlchemy
alembic
psycopg2

This results in the following build log:这会产生以下构建日志:

-----> Python app detected
-----> Installing requirements with pip
       Collecting psycopg2 (from -r /tmp/build_e719ee5ccc3230ba0e40249f52a032c8/j4k0bk-MealoApi-15a38366ac18133eb1495aa651a7cad5497101c3/requirements.txt (line 7))
         Downloading psycopg2-2.7.1.tar.gz (421kB)
       Installing collected packages: psycopg2
         Running setup.py install for psycopg2: started
           Running setup.py install for psycopg2: finished with status 'error'
           Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EVUXmv/psycopg2/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-iefE_6-record/install-record.txt --single-version-externally-managed --compile:
           running install
           running build
           running build_py
           creating build
           creating build/lib.linux-x86_64-2.7
           creating build/lib.linux-x86_64-2.7/psycopg2
           copying lib/tz.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/psycopg1.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/__init__.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/extensions.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/_json.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/_range.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/extras.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/errorcodes.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/pool.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/sql.py -> build/lib.linux-x86_64-2.7/psycopg2
           copying lib/_ipaddress.py -> build/lib.linux-x86_64-2.7/psycopg2
           creating build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/testconfig.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_connection.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_types_extras.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/testutils.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_bugX000.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/__init__.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_with.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/dbapi20.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_transaction.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_types_basic.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_module.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_async.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_copy.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_dates.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_green.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_notify.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_async_keyword.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_lobject.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_bug_gc.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_quote.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_ipaddress.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_cancel.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_cursor.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_replication.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_errcodes.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           copying tests/test_sql.py -> build/lib.linux-x86_64-2.7/psycopg2/tests
           running build_ext
           building 'psycopg2._psycopg' extension
           creating build/temp.linux-x86_64-2.7
           creating build/temp.linux-x86_64-2.7/psycopg
           cc -O2 -fPIC -Wimplicit -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7.1 (dt dec pq3 ext lo64)" -DPG_VERSION_NUM=90602 -DHAVE_LO64=1 -I/app/.heroku/python/include -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.6/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement
           In file included from psycopg/psycopgmodule.c:41:0:
           ./psycopg/error.h:32:5: error: unknown type name ‘PyBaseExceptionObject’
                PyBaseExceptionObject exc;
                ^
           error: command 'cc' failed with exit status 1

           ----------------------------------------
       Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EVUXmv/psycopg2/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-iefE_6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-EVUXmv/psycopg2/
 !     Push rejected, failed to compile Python app.
 !     Push failed

This seems to comply with what Herokus guide on how to connect to PostgreSQL via Python ( https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python ), however i can't seem to find a solution to this problem.这似乎符合 Herokus 关于如何通过 Python 连接到 PostgreSQL 的指南( https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python ),但是我似乎找不到解决方案到这个问题。

So the problem was because i was using the pypy-5.3.1 runtime.所以问题是因为我使用的是pypy-5.3.1运行时。 I changed this to python-2.7.13 and it works.我将其更改为python-2.7.13并且它有效。

remove移除

psycopg2==2.7.* psycopg2==2.7.*

from requirements.txt来自需求.txt

add添加

psycopg2-binary psycopg2-二进制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM