【问题标题】:"cannot find -lpq" when trying to install psycopg2尝试安装 psycopg2 时“找不到 -lpq”
【发布时间】:2010-09-12 16:27:44
【问题描述】:

简介:我正在尝试将 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 选项,但错误消息保持不变。

【问题讨论】:

    标签: python postgresql trac


    【解决方案1】:

    你试过 Windows 版 psycopg2 的 binary build 吗?如果这适用于您的 python,那么它可以减少手动构建的需要。

    我看到随机的人在各种列表中提出这个问题,似乎一个建议是手动构建 postgresql 来解决这个问题。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-02
        • 1970-01-01
        • 1970-01-01
        • 2014-12-04
        • 2020-07-26
        • 2020-01-08
        • 1970-01-01
        相关资源
        最近更新 更多