使用此命令在Amazon Linux上安装psycopg2
时:sudo pip-3.4 install psycopg2
我收到此输出:
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7 (dt dec pq3 ext)" -DPG_VERSION_NUM=90218 -I/usr/include/python3.4m -I. -I/usr/include/pgsql92 -I/usr/include/pgsql92/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from ./psycopg/replication_cursor.h:30:0,
from psycopg/psycopgmodule.c:32:
./psycopg/libpq_support.h:31:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘XLogRecPtr’
typedef unsigned PG_INT64_TYPE XLogRecPtr;
^
In file included from psycopg/psycopgmodule.c:32:0:
./psycopg/replication_cursor.h:47:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr write_lsn; /* LSNs for replication feedback messages */
^
./psycopg/replication_cursor.h:48:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr flush_lsn;
^
./psycopg/replication_cursor.h:49:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr apply_lsn;
^
In file included from psycopg/psycopgmodule.c:33:0:
./psycopg/replication_message.h:46:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr data_start;
^
./psycopg/replication_message.h:47:5: error: unknown type name ‘XLogRecPtr’
XLogRecPtr wal_end;
^
error: command 'gcc' failed with exit status 1
我已经安装了gcc
,postgresql-devel
,postgresql-libs
和python34-devel
。我错过了包装或设置吗?
编辑:这是在EMR节点上。
答案 0 :(得分:1)
我和EMR有同样的问题,我在下面试过
sudo yum -y install gcc python-setuptools python-devel postgresql-devel
sudo /usr/bin/pip install --upgrade pip
sudo /usr/local/bin/pip install psycopg2
当我在EMR上运行它时它起作用,但当EMR从Pipeline中旋转时它不起作用。
答案 1 :(得分:1)
如果您要为python3安装psycopg2,则还必须安装python3-devel。
找到正确的包装
yum search python3 | grep devel
在我的情况下是python36-devel,所以我做了
sudo yum install python36-devel
然后我可以在计算机上为我的python3虚拟环境安装psycopg2
答案 2 :(得分:0)
如果您要在Amazon Linux中为python3寻找psycopg2,这对我有用:
sudo yum install -y gcc postgresql-devel
sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python36
sudo pip-3.6 install -U psycopg2