[英]Building wheel for psycopg2 ... error pip3 install psycopg2?
当我跑步时
pip3 install -r requirements.txt
然后告诉我错误我告诉你我正在使用
python version 3.8
PostgreSQL 13.0 (Ubuntu 13.0-1.pgdg20.04+1)
在这里查看我的requirement.txt文件
certifi==2018.4.16
chardet==3.0.4
click==6.7
croniter==0.3.24
Django==2.0.5
django-rq==1.1.0
et-xmlfile==1.0.1
idna==2.7
jdcal==1.4
lxml==4.2.3
openpyxl==2.5.4
#pkg-resources==0.0.0
psycopg2==2.7.5
psycopg2-binary==2.8.5
python-dateutil==2.7.3
python-decouple==3.1
pytz==2018.5
redis==2.10.6
requests==2.19.1
rq==0.12.0
rq-scheduler==0.8.3
six==1.11.0
Unipath==1.1
urllib3==1.23
所以在终端中告诉我这个错误我与你分享我已经输入的完整命令消息
pip3 install -r requirements.txt ✔ 2186 17:28:42
Requirement already satisfied: certifi==2018.4.16 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 1)) (2018.4.16)
Requirement already satisfied: chardet==3.0.4 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: click==6.7 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (6.7)
Requirement already satisfied: croniter==0.3.24 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (0.3.24)
Requirement already satisfied: Django==2.0.5 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (2.0.5)
Requirement already satisfied: django-rq==1.1.0 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (1.1.0)
Requirement already satisfied: et-xmlfile==1.0.1 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (1.0.1)
Requirement already satisfied: idna==2.7 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (2.7)
Requirement already satisfied: jdcal==1.4 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 9)) (1.4)
Requirement already satisfied: lxml==4.2.3 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 10)) (4.2.3)
Requirement already satisfied: openpyxl==2.5.4 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 11)) (2.5.4)
Collecting psycopg2==2.7.5
Using cached psycopg2-2.7.5.tar.gz (426 kB)
Collecting psycopg2-binary==2.8.5
Downloading psycopg2_binary-2.8.5-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
|████████████████████████████████| 3.0 MB 101 kB/s
Requirement already satisfied: python-dateutil==2.7.3 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 15)) (2.7.3)
Processing /code/data/.cache/pip/wheels/34/e3/10/a284f71c3b99a9ed3ab3d7d6f3af2dd72855bf04aa763dfef5/python_decouple-3.1-py3-none-any.whl
Requirement already satisfied: pytz==2018.5 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 17)) (2018.5)
Collecting redis==2.10.6
Using cached redis-2.10.6-py2.py3-none-any.whl (64 kB)
Collecting requests==2.19.1
Using cached requests-2.19.1-py2.py3-none-any.whl (91 kB)
Collecting rq==0.12.0
Using cached rq-0.12.0-py2.py3-none-any.whl (54 kB)
Collecting rq-scheduler==0.8.3
Using cached rq_scheduler-0.8.3-py2.py3-none-any.whl (14 kB)
Collecting six==1.11.0
Using cached six-1.11.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: Unipath==1.1 in /code/data/.local/lib/python3.8/site-packages (from -r requirements.txt (line 23)) (1.1)
Collecting urllib3==1.23
Using cached urllib3-1.23-py2.py3-none-any.whl (133 kB)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wg77t_ou/psycopg2/setup.py'"'"'; __file__='"
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wg77t_ou/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wg77t_ou/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-_y3ne80g
cwd: /tmp/pip-install-wg77t_ou/psycopg2/
Complete output (72 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
creating build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_replication.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_sql.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130000 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
689 | while (interp->next)
| ^~
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2, psycopg2-binary, python-decouple, redis, urllib3, requests, rq, rq-scheduler, six
Attempting uninstall: psycopg2
Found existing installation: psycopg2 2.8.6
Uninstalling psycopg2-2.8.6:
Successfully uninstalled psycopg2-2.8.6
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wg77t_ou/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wg77t_ou/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-8sijq8ua/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /code/data/.local/include/python3.8/psycopg2
cwd: /tmp/pip-install-wg77t_ou/psycopg2/
Complete output (72 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
creating build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_replication.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_sql.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION=2.7.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=130000 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/13/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
689 | while (interp->next)
| ^~
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of psycopg2
Moving to /code/data/.local/lib/python3.8/site-packages/psycopg2-2.8.6-py3.8.egg-info
from /code/data/.local/lib/python3.8/site-packages/~sycopg2-2.8.6-py3.8.egg-info
Moving to /code/data/.local/lib/python3.8/site-packages/psycopg2/
from /code/data/.local/lib/python3.8/site-packages/~sycopg2
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wg77t_ou/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wg77t_ou/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-8sijq8ua/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /code/data/.local/include/python3.8/psycopg2 Check the logs for full command output.
来自需求.txt
#psycopg2==2.7.5
#psycopg2-binary==2.8.5
当我在上面发表评论时,错误消失了,但数据库绝对不能正常工作。 但是如果我尝试 python3 manage.py runserver 然后告诉我错误
from lawyers.views import *
File "/code/data/abc/proj/lawyers/views.py", line 37, in <module>
from django_rq import job
File "/code/data/.local/lib/python3.8/site-packages/django_rq/__init__.py", line 3, in <module>
from .decorators import job
File "/code/data/.local/lib/python3.8/site-packages/django_rq/decorators.py", line 6, in <module>
from .queues import get_queue
SyntaxError: invalid syntax (queues.py, line 132)
我认为在django_rq 中输入 python3 manage.py runserver 时会出现错误告诉我可能的解决方案谢谢我尝试了很多但没有成功
我解决了我的问题,我的工作基本上也与 python 版本有关,我使用此命令安装了 python 3.7版
sudo apt-get install python3.7
然后激活环境
source env/bin/activate
然后我使用这个命令安装我的requirements.txt文件
python3.7 -m pip install requirements.txt
我的这个错误解决了,不再显示我为 psycopg2 构建轮子……错误 pip3 安装 psycopg2?
那让我看看
ModuleNotFoundError: No module named 'pandas'然后我用这种方式安装
python3.7 -m pip install pandas
当我运行python3.7 manage.py runserver
然后告诉我错误是django-rq
/code/data/.local/lib/python3.7/site-packages/django_rq/queues.py", line 132
def get_queue(name='default', default_timeout=None, async=None,
^
我这样 async 现在在 python 中是保留字,然后在我的包中,当我再次运行项目时,我将整个django-rq/queues.py
的async
名称替换为is_async
,然后显示此错误
import xlsxwriter
ModuleNotFoundError: No module named 'xlsxwriter'
然后我通过这种方式修复
python3.7 -m pip install xlsxwriter
然后再给我看一个错误
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
然后我用这种方式固定
python3.7 -m pip install bs4
然后我的项目工作正常。 我希望我的解决方案对任何人都有帮助。 我暂时需要 python3.7 版本,所以我不想将它们的路径更改为 python3 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.