我在一个知名的networking托pipe公司的共享服务器上,这里是我的Linux版本的细节。 我在这里添加所有的命令,以便解答提供者在应答之前拥有所有的信息。
$ uname -a Linux somehosting.com 2.6.32-673.8.1.lve1.4.3.el6.x86_64 #1 SMP Wed Feb 10 08:57:30 EST 2016 x86_64 x86_64 x86_64 GNU/Linux $ cat /proc/version Linux version 2.6.32-673.8.1.lve1.4.3.el6.x86_64 (mockbuild@build.cloudlinux.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP Wed Feb 10 08:57:30 EST 2016 $ cat /etc/*release* CloudLinux Server release 6.8 (Oleg Makarov) CloudLinux Server release 6.8 (Oleg Makarov) cpe:/o:redhat:enterprise_linux:6:ga:server
我想要达到什么目的?
我需要在我的系统上安装psycopg2。
我到现在为止做了什么?
oauth2client需要Python 2.7或者Python 3+,但是我的共享主机提供了Python 2.6。 所以,到现在为止,我已经成功地在我的共享服务器上安装了Python 3.5.3和Pip。
我现在正在做什么?
现在,我正在通过我的系统上的源代码安装psycopg2(系统的细节在开头提到)
我面临什么问题?
请参阅以下内容来了解问题。
[myname psycopg2-2.6.2]$ python setup.py install running install running bdist_egg running egg_info writing psycopg2.egg-info/PKG-INFO writing dependency_links to psycopg2.egg-info/dependency_links.txt writing top-level names to psycopg2.egg-info/top_level.txt reading manifest file 'psycopg2.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'psycopg2.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py running build_ext building 'psycopg2._psycopg' extension gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x09030F -DHAVE_LO64=1 -I/home/amanka5/python/Python-3.5.2/Include -I/home/amanka5/python/Python-3.5.2 -I. -I/usr/pgsql-9.3/include -I/usr/pgsql-9.3/include/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.5/psycopg/psycopgmodule.o -Wdeclaration-after-statement In file included from psycopg/psycopgmodule.c:27: ./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory In file included from psycopg/psycopgmodule.c:29: ./psycopg/connection.h:98: error: expected specifier-qualifier-list before 'PGconn' ./psycopg/connection.h:135: error: expected ')' before '*' token ./psycopg/connection.h:137: error: expected ')' before '*' token ./psycopg/connection.h:138: error: expected ')' before '*' token ./psycopg/connection.h:142: error: expected declaration specifiers or '...' before 'PGconn' In file included from psycopg/psycopgmodule.c:30: ./psycopg/cursor.h:63: error: expected specifier-qualifier-list before 'PGresult' In file included from psycopg/psycopgmodule.c:31: ./psycopg/green.h:63: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token In file included from psycopg/psycopgmodule.c:32: ./psycopg/lobject.h:29:28: error: libpq/libpq-fs.h: No such file or directory In file included from psycopg/psycopgmodule.c:32: ./psycopg/lobject.h:49: error: expected specifier-qualifier-list before 'Oid' ./psycopg/lobject.h:55: error: expected declaration specifiers or '...' before 'Oid' ./psycopg/lobject.h:55: error: expected declaration specifiers or '...' before 'Oid' In file included from psycopg/psycopgmodule.c:38: ./psycopg/error.h:38: error: expected specifier-qualifier-list before 'PGresult' psycopg/psycopgmodule.c: In function 'psyco_register_type': psycopg/psycopgmodule.c:154: error: 'cursorObject' has no member named 'string_types' psycopg/psycopgmodule.c:161: error: 'connectionObject' has no member named 'string_types' psycopg/psycopgmodule.c: In function 'psyco_libcrypto_threads_init': psycopg/psycopgmodule.c:191: warning: implicit declaration of function 'PQinitOpenSSL' error: command 'gcc' failed with exit status 1
我在找什么答案?
我正在接受这个海湾合作委员会的问题,但在C中的基本问候世界程序输出完美。 我已经阅读了几乎所有在这里stackoverflow的答案,但我找不到任何地方的问题的答案。 我甚至尝试使用pip来安装psycopg2,并且如上所述给出了相同的错误。 那么,这个问题的解决scheme是什么? 我无法弄清楚,需要帮助。 没有psycopg2,我将无法连接到我的PostgreSQL v9.3数据库,这是我真正需要的。
其他一些相关的细节(我的gcc版本)
$ gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
这里的问题是编译失败,由于缺少一个库: libpq-dev
。
您可以在以下日志消息中看到:
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x09030F -DHAVE_LO64=1 -I/home/amanka5/python/Python-3.5.2/Include -I/home/amanka5/python/Python-3.5.2 -I. -I/usr/pgsql-9.3/include -I/usr/pgsql-9.3/include/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.5/psycopg/psycopgmodule.o -Wdeclaration-after-statement In file included from psycopg/psycopgmodule.c:27: ./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory
要解决这个问题,你需要安装postgresql开发人员库。 在类似Redhat的Linux上,这个包叫做postgresql-devel
。 以下命令将安装缺少的库:
yum install postgresql-devel