简体   繁体   English

尝试安装psycopg2时“找不到-lpq”

[英]“cannot find -lpq” when trying to install psycopg2

Intro : I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. 简介 :我正在尝试将Trac SQLite迁移到PostgreSQL后端,为此我需要psycopg2。 After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running setup.py install . 单击www.initd.org上令人尴尬的选项后,我下载了最新版本并尝试运行setup.py install This didn't work, telling me I needed mingw. 这没用,告诉我我需要mingw。 So I downloaded and installed mingw. 因此,我下载并安装了mingw。

Problem : I now get the following error when running setup.py build_ext --compiler=mingw32 install : 问题 :运行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

What I've tried - I noticed the forward slashes in the -L option, so I manually entered my PostgreSQL lib directory in the library_dirs option in the setup.cfg, to no avail (the call then had a -L option with backslashes, but the error message stayed the same). 我尝试过的 -我注意到-L选项中的正斜杠,因此我在setup.cfg的library_dirs选项中手动输入了我的PostgreSQL lib目录,但无济于事(该调用中有一个带有反斜杠的-L选项,但错误消息保持不变)。

Have you tried the binary build of psycopg2 for windows? 您是否尝试过Windows的psycopg2的二进制版本 If that works with your python then it mitigates the need to build by hand. 如果这适用于您的python,则可以减轻手工构建的需要。

I've seen random people ask this question on various lists and it seems one recommendation is to build postgresql by hand to work around this problem. 我已经看到随机的人在各种各样的列表上问这个问题,似乎一个建议是手工构建postgresql来解决这个问题。

Compiling extensions on windows can be tricky. 在Windows上编译扩展可能很棘手。 There are precompiled libraries available however: http://www.stickpeople.com/projects/python/win-psycopg/ 但是,有可用的预编译库: http : //www.stickpeople.com/projects/python/win-psycopg/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM