python - 当我使用 pip install psycopg2 构建 docker 时出现错误
问题描述
the error:
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
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7.3.1 (dt dec pq3 ext lo64)" -DPG_VERSION_NUM=110500 -DHAVE_LO64=1 -I/usr/local/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/11/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:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
while (interp->next)
^~
error: command 'gcc' failed with exit status 1
当我构建 dockerc-compose 来 pip install psycopg2 并遇到问题时。
Dockerfile:
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
RUN cat /etc/apt/sources.list
RUN apt-get clean && apt-get update
RUN apt-get install -y python3-dev \
&& apt-get install -y libevent-dev \
&& pip install --default-timeout=1000 --no-cache-dir -r requirements.txt
解决方案
您正在尝试构建 psycopg2 版本 2.7.3.1:该版本与 Python 3.8 不兼容。
您必须使用至少 2.8.4 的 psycopg2 版本。
https://www.psycopg.org/docs/news.html#what-s-new-in-psycopg-2-8-4
推荐阅读
- maven - Maven 项目初始化程序
- testing - 我是 Protractor 测试的新手,请您告诉我如何为登录网页编写脚本并转到下一页
- google-chrome - 在 Windows 和 Android 上使用 Chrome 选择证书
- python - 如何根据其他非相关模型过滤django模型
- java - Spring - 使用 x-www-form-urlencoded 错误编码 POST 请求
- c# - EF 两个干扰上下文
- ionic-framework - Ionic 4 build for release 不工作,调试 apk 工作
- json - 如何在sql查询中调用Json
- c - printf() 重定向到命令行中的文件 (Cygwin)
- django - 对于轮询其他 API 的 API,我应该使用任务队列 (Celery)、ayncio 还是都不使用?