代码之家  ›  专栏  ›  技术社区  ›  Jakob Kristensen

Heroku无法安装psycopg2

  •  0
  • Jakob Kristensen  · 技术社区  · 9 年前

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

    这将导致以下生成日志:

    -----> 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
    

    这似乎符合Herokus关于如何通过Python连接到PostgreSQL的指南( https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python

    2 回复  |  直到 9 年前
        1
  •  1
  •   Jakob Kristensen    9 年前

    所以问题是因为我使用了 运行时。我把这个改成了 python-2.7.13 这是可行的。

        2
  •  0
  •   gujaratiraja    6 年前

    去除

    psycopg2==2.7*

    psycopg2二进制