首页 > 解决方案 > 根据错误日志为 psycopg2-“pip”问题构建轮子时出错?

问题描述

我一直在尝试安装psycopg2一段时间,但每次遇到ERROR: Failed building wheel for psycopg2.

我已经写信给维护 psycopg2 的人,他说这是个pip问题;请在此处查看简短的会议:https ://github.com/psycopg/psycopg2/issues/1331

以下是错误日志:

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-gtbzh5wa/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gtbzh5wa/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-lr6q7nda
remote:               cwd: /tmp/pip-install-gtbzh5wa/psycopg2/

remote:          psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
remote:          psycopg/psycopgmodule.c:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
remote:            685 |     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 alembic blinker dominate Flask-Bootstrap Flask-Mail guess-language-spirit itsdangerous Mako python-editor visitor WTForms
remote:        Failed to build psycopg2
remote:        Installing collected packages: SQLAlchemy, MarkupSafe, Mako, python-editor, six, python-dateutil, alembic, pytz, Babel, blinker, certifi, chardet, click, dnspython, dominate, urllib3, elasticsearch, idna, email-validator, Jinja2, itsdangerous, Werkzeug, Flask, Flask-Babel, visitor, Flask-Bootstrap, Flask-Login, Flask-Mail, Flask-SQLAlchemy, Flask-Migrate, Flask-Moment, WTForms, Flask-WTF, guess-language-spirit, PyJWT, python-dotenv, requests, psycopg2, gunicorn
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-gtbzh5wa/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gtbzh5wa/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-w8vdwemp/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/psycopg2
remote:                 cwd: /tmp/pip-install-gtbzh5wa/psycopg2/




remote:            psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
remote:            psycopg/psycopgmodule.c:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
remote:              685 |     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-gtbzh5wa/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gtbzh5wa/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-w8vdwemp/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: 051cab19b48ea2b11b7471f753d7d88b06c0030d
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 051cab19b48ea2b11b7471f753d7d88b06c0030d
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 patrickchong-blog.
remote: 
To https://git.heroku.com/patrickchong-blog.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/patrickchong-blog.git'

标签: pippsycopg2

解决方案


推荐阅读