【问题标题】:Cygwin 32 and Python 2.7.5: psycopg2 installation errorCygwin 32 和 Python 2.7.5:psycopg2 安装错误
【发布时间】:2013-08-21 19:12:41
【问题描述】:

在我的previous question 中,我描述了我们的情况:我们的开发人员将在 Windows 7 - 64 位的 cygwin 环境中使用 python,但是测试在构建期间以及在 linux 上自动执行。我们在使用 cygwin64 时遇到了一些问题,所以现在我们尝试在 cygwin32 上使用 python。

遗憾的是,在安装 psycopg2 期间,似乎同时使用 64 位和 32 位版本的 PostgreSQL 9.2 会导致 gcc 编译错误。 32位版本安装日志:

$ pip install psycopg2

...

下载/解压 psycopg2 下载 psycopg2-2.5.1.tar.gz (684kB):已下载 684kB 为包 psycopg2 运行 setup.py egg_info

安装收集的包:psycopg2 为 psycopg2 运行 setup.py install 构建“psycopg2._psycopg”扩展 gcc -fno-strict-aliasing -ggdb -O2 -pipe -fdebug-prefix-map=/home/jt/rel/python-2.7.3-1/python-2.7.3-1/build=/usr/src/调试/python-2.7.3-1 -fdebug-prefix-map=/home/jt/rel/python-2.7.3-1/python-2.7.3-1/src/Python-2.7.3=/usr/ src/debug/python-2.7.3-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.1 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090204 -DPSYCOPG_EXTENSIONS= 1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/include/python2.7 -I。 -IC:/PROGRA~2/POSTGR~1/9.2/include -IC:/PROGRA~2/POSTGR~1/9.2/include/server -c psycopg/psycopgmodule.c -o build/temp.cygwin-1.7.24 -i686-2.7/psycopg/psycopgmodule.o

In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:307:8: error: redefinition of ‘struct timespec’
In file included from /usr/include/stdio.h:47:0,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/sys/types.h:130:8: note: originally defined here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:571:24: error: conflicting types for ‘pthread_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:178:45: note: previous declaration of ‘pthread_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:572:34: error: conflicting types for ‘pthread_attr_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:182:50: note: previous declaration of ‘pthread_attr_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:573:32: error: conflicting types for ‘pthread_once_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:193:1: note: previous declaration of ‘pthread_once_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:574:33: error: conflicting types for ‘pthread_key_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:181:49: note: previous declaration of ‘pthread_key_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:575:35: error: conflicting types for ‘pthread_mutex_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:179:51: note: previous declaration of ‘pthread_mutex_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:576:39: error: conflicting types for ‘pthread_mutexattr_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:183:55: note: previous declaration of ‘pthread_mutexattr_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:577:34: error: conflicting types for ‘pthread_cond_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:185:50: note: previous declaration of ‘pthread_cond_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:578:38: error: conflicting types for ‘pthread_condattr_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:184:54: note: previous declaration of ‘pthread_condattr_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:580:36: error: conflicting types for ‘pthread_rwlock_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:195:52: note: previous declaration of ‘pthread_rwlock_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:581:40: error: conflicting types for ‘pthread_rwlockattr_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:196:56: note: previous declaration of ‘pthread_rwlockattr_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:582:38: error: conflicting types for ‘pthread_spinlock_t’
In file included from /usr/include/sys/types.h:473:0,
                 from /usr/include/stdio.h:47,
                 from /usr/include/python2.7/Python.h:33,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/cygwin/types.h:194:54: note: previous declaration of ‘pthread_spinlock_t’ was here
In file included from ./psycopg/config.h:120:0,
                 from ./psycopg/psycopg.h:33,
                 from psycopg/psycopgmodule.c:27:
C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:1131:31: error: conflicting types for ‘pthread_kill’
In file included from /usr/include/signal.h:5:0,
                 from /usr/include/time.h:138,
                 from /usr/include/sys/select.h:24,
                 from /usr/include/cygwin/sys_time.h:13,
                 from /usr/include/sys/time.h:61,
                 from /usr/include/python2.7/pyport.h:319,
                 from /usr/include/python2.7/Python.h:58,
                 from ./psycopg/psycopg.h:30,
                 from psycopg/psycopgmodule.c:27:
/usr/include/sys/signal.h:170:5: note: previous declaration of ‘pthread_kill’ was here
error: command 'gcc' failed with exit status 1

...

C:/PROGRA~2/POSTGR~1/9.2/include/pthread.h:1131:31:错误:“pthread_kill”的类型冲突

在 /usr/include/signal.h:5:0 包含的文件中,

             from /usr/include/time.h:138,

             from /usr/include/sys/select.h:24,

             from /usr/include/cygwin/sys_time.h:13,

             from /usr/include/sys/time.h:61,

             from /usr/include/python2.7/pyport.h:319,

             from /usr/include/python2.7/Python.h:58,

             from ./psycopg/psycopg.h:30,

             from psycopg/psycopgmodule.c:27:

/usr/include/sys/signal.h:170:5: 注意:之前声明的‘pthread_kill’在这里 错误:命令“gcc”失败,退出状态为 1

...

我们安装了 cygwin 安装包附带的标准 Gcc 和 PostgreSQL 库。下一步该做什么?

非常感谢您: 乔,公众

【问题讨论】:

    标签: python-2.7 cygwin postgresql-9.2 psycopg2


    【解决方案1】:

    与 PostgreSQL 安装程序捆绑在一起的 libpq 使用 Microsoft Visual Studio 编译为原生 Windows 二进制文件。

    如果从 Cygwin 链接到它碰巧有效,那主要是运气。这不是一个好主意。您确实需要使用为 Cygwin 构建的 libpq 和 Cygwin 程序。

    坦率地说,我认为这些天你最好只使用本机 Windows 并完全避免使用 Cygwin。当您需要类似 unix 的构建系统时,您可以将 mingw 编译器与 msys 一起使用,并且正确编写的 Windows 兼容代码可以很好地处理混合 mingw 和 msvc 编译的二进制文件。

    在你的情况下,我只需要install ActivePython,或者我会安装stock Python build,然后是add psycopg2 myself

    【讨论】:

    • 非常感谢克雷格!不幸的是,由于“pexpect”平台依赖性,我们不能使用现有的 python 解决方案。您能否详细说明如何使用 cygwin libpq?我在 cygwin 安装过程中安装了“PostgreSQL 的客户端 C 库”。接下来做什么?提前感谢:乔
    • @JoePublic 确保 cygwin 客户端库中包含的 pg_config 在您的 PATH 上,并且 c:\program files\PostgreSQL\... 在您的 PATH 上。应该这样做。
    • 谢谢克雷格!实际上,我们决定以两种并行的方式继续前进:重新实现我们的库以在 windows 上使用 winpexpect,否则在 linux 上使用虚拟工具箱。正如您所说:如果“Cygwin 恰好工作,那主要是运气”。
    • @JoePublic “虚拟工具箱”?
    猜你喜欢
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 2020-05-31
    • 1970-01-01
    • 2023-03-25
    相关资源
    最近更新 更多