简介:我正在尝试将Trac SQLite迁移到PostgreSQL后端,为此我需要psycopg2。点击www.initd.org上的尴尬咆哮后,我下载了最新版本并尝试运行 setup.py install 。这没用,告诉我我需要mingw。所以我下载并安装了mingw。

问题:运行 setup.py build_ext --compiler = mingw32 install 时,我现在收到以下错误:

running build_ext
building 'psycopg2._psycopg' extension
writing build\temp.win32-2.4\Release\psycopg\_psycopg.def
C:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.4\Release\psycopg
\psycopgmodule.o build\temp.win32-2.4\Release\psycopg\pqpath.o build\temp.win32-
2.4\Release\psycopg\typecast.o build\temp.win32-2.4\Release\psycopg\microprotoco
ls.o build\temp.win32-2.4\Release\psycopg\microprotocols_proto.o build\temp.win3
2-2.4\Release\psycopg\connection_type.o build\temp.win32-2.4\Release\psycopg\con
nection_int.o build\temp.win32-2.4\Release\psycopg\cursor_type.o build\temp.win3
2-2.4\Release\psycopg\cursor_int.o build\temp.win32-2.4\Release\psycopg\lobject_
type.o build\temp.win32-2.4\Release\psycopg\lobject_int.o build\temp.win32-2.4\R
elease\psycopg\adapter_qstring.o build\temp.win32-2.4\Release\psycopg\adapter_pb
oolean.o build\temp.win32-2.4\Release\psycopg\adapter_binary.o build\temp.win32-
2.4\Release\psycopg\adapter_asis.o build\temp.win32-2.4\Release\psycopg\adapter_
list.o build\temp.win32-2.4\Release\psycopg\adapter_datetime.o build\temp.win32-
2.4\Release\psycopg\_psycopg.def -LC:\Python24\libs -LC:\Python24\PCBuild -Lc:/P
ROGRA~1/POSTGR~1/8.3/lib -lpython24 -lmsvcr71 -lpq -lmsvcr71 -lws2_32 -ladvapi32
 -o build\lib.win32-2.4\psycopg2\_psycopg.pyd
C:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot fin
d -lpq
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

我尝试了什么 - 我注意到-L选项中的正斜杠,所以我在setup.cfg的library_dirs选项中手动输入了我的PostgreSQL lib目录,但没有用(然后调用带有反斜杠的-L选项,但错误消息保持不变)。

有帮助吗?

解决方案

您是否尝试过针对Windows的psycopg2的二进制构建?如果它适用于您的python,那么它可以减少手动构建的需要。

我见过随机的人在各种列表上提出这个问题,似乎有一个建议是手工构建postgresql来解决这个问题。

其他提示

在Windows上编译扩展可能很棘手。但是有预编译的库可用: http://www.stickpeople.com/projects/蟒/ WIN-psycopg /

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top