【问题标题】:Why does my django app fail to deploy to heroku ("building wheel for psycopg2")?为什么我的 django 应用程序无法部署到 heroku(“psycopg2 的构建轮”)?
【发布时间】:2021-08-18 18:22:46
【问题描述】:

在尝试将 django 应用程序部署到 heroku 时,我遇到了一个我似乎无法解决的问题,而且我越来越绝望。

当我输入命令时

git push heroku master

遇到以下错误

remote:          Collecting sqlparse>=0.2.2
remote:          Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
remote:          Building wheels for collected packages: Pillow, psycopg2
remote:          Building wheel for Pillow (setup.py): started
remote:          Building wheel for Pillow (setup.py): finished with status 'done'
remote:          Created wheel for Pillow: filename=Pillow-5.2.0-cp39-cp39-linux_x86_64.whl size=1316371 sha256=cb80053184568f78e761e74c93e38682de7c3000417f9d12e7b37971f12dfcd0
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-4bhzio_g/wheels/2e/0c/21/df64563df0fe8750c4bff3e38b90f223df6c02aa5c5b570905
remote:          Building wheel for psycopg2 (setup.py): started
remote:          Building wheel for psycopg2 (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tajnjqcx/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tajnjqcx/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-9ekv4vgu
remote:               cwd: /tmp/pip-install-tajnjqcx/psycopg2/

据我了解,它会尝试在我的 requirements.txt 文件中安装依赖项。

我试过了

  1. 将 psycopg2 更改为 psycopg2-binary
  2. 更改 psycopg2 的版本号
  3. 完全删除它

一切都无济于事:它仍然试图为它“造轮子”。我真的不知道这个错误是什么意思,我完全不知所措。这是完整的控制台输出。

Enumerating objects: 937, done.
Counting objects: 100% (937/937), done.
Delta compression using up to 4 threads
Compressing objects: 100% (711/711), done.
Writing objects: 100% (937/937), 400.51 KiB | 3.08 MiB/s, done.
Total 937 (delta 620), reused 271 (delta 173)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the buildpack default: python-3.9.6
remote:        To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.9.6
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting Django==3.1.7
remote:          Downloading Django-3.1.7-py3-none-any.whl (7.8 MB)
remote:        Collecting djangorestframework==3.12.4
remote:          Downloading djangorestframework-3.12.4-py3-none-any.whl (957 kB)
remote:        Collecting boto3==1.9.96
remote:          Downloading boto3-1.9.96-py2.py3-none-any.whl (128 kB)
remote:        Collecting botocore==1.12.96
remote:          Downloading botocore-1.12.96-py2.py3-none-any.whl (5.3 MB)
remote:        Collecting certifi==2018.10.15
remote:          Downloading certifi-2018.10.15-py2.py3-none-any.whl (146 kB)
remote:        Collecting chardet==3.0.4
remote:          Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
remote:        Collecting dj-database-url==0.5.0
remote:          Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
remote:        Collecting django-crispy-forms==1.7.2
remote:          Downloading django_crispy_forms-1.7.2-py2.py3-none-any.whl (105 kB)
remote:        Collecting django-heroku==0.3.1
remote:          Downloading django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
remote:        Collecting django-storages==1.7.1
remote:          Downloading django_storages-1.7.1-py2.py3-none-any.whl (44 kB)
remote:        Collecting docutils==0.14
remote:          Downloading docutils-0.14-py3-none-any.whl (543 kB)
remote:        Collecting gunicorn==19.9.0
remote:          Downloading gunicorn-19.9.0-py2.py3-none-any.whl (112 kB)
remote:        Collecting idna==2.7
remote:          Downloading idna-2.7-py2.py3-none-any.whl (58 kB)
remote:        Collecting jmespath==0.9.3
remote:          Downloading jmespath-0.9.3-py2.py3-none-any.whl (23 kB)
remote:        Collecting Pillow==5.2.0
remote:          Downloading Pillow-5.2.0.tar.gz (14.5 MB)
remote:        Collecting psycopg2==2.7.7
remote:          Downloading psycopg2-2.7.7.tar.gz (427 kB)
remote:        Collecting python-dateutil==2.8.0
remote:          Downloading python_dateutil-2.8.0-py2.py3-none-any.whl (226 kB)
remote:        Collecting pytz==2018.5
remote:          Downloading pytz-2018.5-py2.py3-none-any.whl (510 kB)
remote:        Collecting requests==2.19.1
remote:          Downloading requests-2.19.1-py2.py3-none-any.whl (91 kB)
remote:        Collecting s3transfer==0.2.0
remote:          Downloading s3transfer-0.2.0-py2.py3-none-any.whl (69 kB)
remote:        Collecting six==1.12.0
remote:          Downloading six-1.12.0-py2.py3-none-any.whl (10 kB)
remote:        Collecting urllib3==1.23
remote:          Downloading urllib3-1.23-py2.py3-none-any.whl (133 kB)
remote:        Collecting whitenoise==4.1.2
remote:          Downloading whitenoise-4.1.2-py2.py3-none-any.whl (19 kB)
remote:        Collecting asgiref<4,>=3.2.10
remote:          Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
remote:        Collecting sqlparse>=0.2.2
remote:          Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
remote:        Building wheels for collected packages: Pillow, psycopg2
remote:          Building wheel for Pillow (setup.py): started
remote:          Building wheel for Pillow (setup.py): finished with status 'done'
remote:          Created wheel for Pillow: filename=Pillow-5.2.0-cp39-cp39-linux_x86_64.whl size=1316392 sha256=69fcc0f3c66aa43e6908ae3b4beeece5cfe2f390d14b07f43084b461fff5b94c
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-6qfrrkl1/wheels/2e/0c/21/df64563df0fe8750c4bff3e38b90f223df6c02aa5c5b570905
remote:          Building wheel for psycopg2 (setup.py): started
remote:          Building wheel for psycopg2 (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jic1i6ze/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jic1i6ze/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-k6s2rfim
remote:               cwd: /tmp/pip-install-jic1i6ze/psycopg2/
remote:          Complete output (86 lines):
remote:          running bdist_wheel
remote:          running build
remote:          running build_py
remote:          creating build
remote:          creating build/lib.linux-x86_64-3.9
remote:          creating build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/pool.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/_json.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/__init__.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/extras.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/_range.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/extensions.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/errorcodes.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/tz.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/psycopg1.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          copying lib/sql.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:          creating build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_quote.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_with.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_sql.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_replication.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_copy.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_cursor.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/__init__.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/testutils.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_connection.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_async.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/testconfig.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_module.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_notify.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_green.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_cancel.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_dates.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_lobject.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/dbapi20.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_transaction.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:          Skipping optional fixer: buffer
remote:          Skipping optional fixer: idioms
remote:          Skipping optional fixer: set_literal
remote:          Skipping optional fixer: ws_comma
remote:          running build_ext
remote:          building 'psycopg2._psycopg' extension
remote:          creating build/temp.linux-x86_64-3.9
remote:          creating build/temp.linux-x86_64-3.9/psycopg
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-3.9/psycopg/adapter_asis.o -Wdeclaration-after-statement


[...]



remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/error_type.c -o build/temp.linux-x86_64-3.9/psycopg/error_type.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/green.c -o build/temp.linux-x86_64-3.9/psycopg/green.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/libpq_support.c -o build/temp.linux-x86_64-3.9/psycopg/libpq_support.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/lobject_int.c -o build/temp.linux-x86_64-3.9/psycopg/lobject_int.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/lobject_type.c -o build/temp.linux-x86_64-3.9/psycopg/lobject_type.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/microprotocols.c -o build/temp.linux-x86_64-3.9/psycopg/microprotocols.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/microprotocols_proto.c -o build/temp.linux-x86_64-3.9/psycopg/microprotocols_proto.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/notify_type.c -o build/temp.linux-x86_64-3.9/psycopg/notify_type.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/pqpath.c -o build/temp.linux-x86_64-3.9/psycopg/pqpath.o -Wdeclaration-after-statement
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.9/psycopg/psycopgmodule.o -Wdeclaration-after-statement
remote:          psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
remote:          psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
remote:            689 |     while (interp->next)
remote:                |                  ^~
remote:          error: command '/usr/bin/gcc' failed with exit code 1
remote:          ----------------------------------------
remote:          ERROR: Failed building wheel for psycopg2
remote:          Running setup.py clean for psycopg2
remote:        Successfully built Pillow
remote:        Failed to build psycopg2
remote:        Installing collected packages: asgiref, pytz, sqlparse, Django, djangorestframework, six, python-dateutil, urllib3, docutils, jmespath, botocore, s3transfer, boto3, certifi, chardet, dj-database-url, django-crispy-forms, whitenoise, psycopg2, django-heroku, django-storages, gunicorn, idna, Pillow, requests
remote:            Running setup.py install for psycopg2: started
remote:            Running setup.py install for psycopg2: finished with status 'error'
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jic1i6ze/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jic1i6ze/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-record-3lnkpduv/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/psycopg2
remote:                 cwd: /tmp/pip-install-jic1i6ze/psycopg2/
remote:            Complete output (86 lines):
remote:            running install
remote:            running build
remote:            running build_py
remote:            creating build
remote:            creating build/lib.linux-x86_64-3.9
remote:            creating build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/pool.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/_json.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/__init__.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/extras.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/_range.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/extensions.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/errorcodes.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/tz.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/psycopg1.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            copying lib/sql.py -> build/lib.linux-x86_64-3.9/psycopg2
remote:            creating build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_quote.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_with.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_sql.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_replication.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_copy.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_cursor.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/__init__.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/testutils.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_connection.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_async.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/testconfig.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_module.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_notify.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_green.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_cancel.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_dates.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_lobject.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/dbapi20.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_transaction.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.9/psycopg2/tests
remote:            Skipping optional fixer: buffer
remote:            Skipping optional fixer: idioms
remote:            Skipping optional fixer: set_literal
remote:            Skipping optional fixer: ws_comma
remote:            running build_ext
remote:            building 'psycopg2._psycopg' extension
remote:            creating build/temp.linux-x86_64-3.9
remote:            creating build/temp.linux-x86_64-3.9/psycopg
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-3.9/psycopg/adapter_asis.o -Wdeclaration-after-statement
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/adapter_binary.c -o build/temp.linux-x86_64-3.9/psycopg/adapter_binary.o -Wdeclaration-after-statement


[...]


remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/microprotocols_proto.c -o build/temp.linux-x86_64-3.9/psycopg/microprotocols_proto.o -Wdeclaration-after-statement
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/notify_type.c -o build/temp.linux-x86_64-3.9/psycopg/notify_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/pqpath.c -o build/temp.linux-x86_64-3.9/psycopg/pqpath.o -Wdeclaration-after-statement
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.7 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -I/app/.heroku/python/include/python3.9 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.9/psycopg/psycopgmodule.o -Wdeclaration-after-statement
remote:            psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
remote:            psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
remote:              689 |     while (interp->next)
remote:                  |                  ^~
remote:            error: command '/usr/bin/gcc' failed with exit code 1
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jic1i6ze/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jic1i6ze/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-record-3lnkpduv/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/psycopg2 Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 8ee480c755d5463f245c3ee4e08f878693eb2773
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 8ee480c755d5463f245c3ee4e08f878693eb2773
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to <myproject>

我真的很想继续这个项目,但不知道怎么做。任何帮助表示赞赏。提前致谢!

【问题讨论】:

  • 我在安装“psycopg2”软件包时遇到了几个问题,请尝试使用“psycopg2-binary”,因为它不需要编译
  • 感谢您的回复。我试图这样做,但它仍然没有工作。我在 requirements.txt 文件中所做的更改似乎没有影响部署。

标签: python django heroku


【解决方案1】:

我想我记得以前遇到过这个问题。我已经能够按照本教程成功部署多个 Django 应用程序:https://youtu.be/GMbVzl_aLxM 试一试,如果有帮助,请告诉我

【讨论】:

  • 感谢您的帮助,很抱歉这么长的回复时间,我刚开始尝试。可悲的是,我一直遇到同样的问题。一切正常,直到 8:30 分钟,当我尝试将项目推送到 heroku 时,出现了构建轮的问题。你对可以做什么有什么想法吗?非常感谢!
  • 遗憾的是,我没有太多的想法。您是否尝试过使用最新的 psycopy2 版本?此外,正如您所说的 requirements.txt 文件中的更改没有被反映,您可以尝试创建一个全新的存储库以查看是否有帮助。
猜你喜欢
  • 2021-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-22
  • 2017-08-27
  • 2018-12-12
  • 2021-12-25
相关资源
最近更新 更多