想在 python 脚本中使用 psycopg2 包。好像无法加载。
我加载了这个 pip 安装 psycopg2-二进制文件 默认为用户安装,因为普通站点包不可写 已满足要求: /usr/local/lib64/python3.6/site-packages (2.7.5) 中的 psycopg2-binary
得到这个 文件“/home/adm_bbyers6/rrd_get/scripts/postgres_crud.py”,第 4 行,位于 导入psycopg2 导入错误:没有名为 psycopg2 的模块
这个“pip install psycopg2”
pip 安装 psycopg2-binary
给了我这个问题
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 - grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.9.8 (dt dec pq3 ext) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=90224 -DPSYCOPG_DEBUG=1 -I/usr/include/ python3.6m-I。 -I/usr/include -I/usr/include/pgsql/server -I/usr/include/libxml2 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration - 声明后
在 psycopg/psycopgmodule.c:28:0 包含的文件中:
./psycopg/psycopg.h:35:20:致命错误:Python.h:没有这样的文件或目录
#包括
试试这个。
pip3 install pyscopg-binary
test.py
的 python 文件并在其中输入以下内容:import pyscopg-binary
print("It works!")
python3 test.py
这基本上就是我认为你所做的,除了我使用了 pip 和 python 的 python3 和 pip3 安装。请记住,python 和 python3 是完全不同的二进制文件。 Python是Python2。 希望这对您有用...编码快乐!