我可以使用 vc9 构建的 python 让 psycopg2 在 Windows 上工作吗?
我有一个类似于 ImportError: DLL load 的问题失败:-当尝试导入 psycopg2 库时,
我尝试使用使用 Visual Studio 2008 (vc9) 构建的 Python 2.6.5 运行 psycopg2。我收到此错误:
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: DLL load failed: The operating system cannot run %1.
来自 PostGres 8.4 的 libpg.dll 位于路径中。如果我用 vc6 构建的 python 构建 psycopg2,它将 运行良好。但问题是我需要它与 vc9 构建的 Python 一起工作。
我引用的页面提到使用旧版本。当我尝试构建版本 2.12.0(甚至 2.10.0)时, 我收到此错误:
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -DPSYCOPG_DEFAULT_PYDATETIME=1 "-DPSYCOPG_VERSION=\"2.0.10 (dt d
ec ext pq3)\"" -DPG_VERSION_HEX=0x080401 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BO
OLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -IC:\Python26\include -IC:\Pytho
n26\PC -I. -Ic:/apps/POSTGR~1/8.4/include -Ic:/apps/POSTGR~1/8.4/include/server
/Tcpsycopg\connection_int.c /Fobuild\temp.win32-2.6\Release\psycopg\connection_i
nt.obj /Wp64
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release
connection_int.c
psycopg\connection_int.c(70) : error C2143: syntax error : missing ';' before 't
ype'
psycopg\connection_int.c(71) : error C2065: 'notice' : undeclared identifier
psycopg\connection_int.c(71) : warning C4047: '=' : 'int' differs in levels of i
ndirection from 'connectionObject_notice *'
psycopg\connection_int.c(73) : error C2065: 'notice' : undeclared identifier
psycopg\connection_int.c(73) : warning C4047: '!=' : 'int' differs in levels of
indirection from 'void *'
等等...查看 C 代码,没有条件代码 包装 struct connectionObject_notice 的定义,所以我不 看看什么会触发这个错误。
最后,上述帖子中的海报提到了“PG6000”。那是什么?
- 埃里克
I have a question similar to ImportError: DLL load failed : - when trying to import psycopg2 library
I'm trying to run psycopg2 with Python 2.6.5, built with Visual Studio 2008 (vc9). I get this error:
from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: DLL load failed: The operating system cannot run %1.
libpg.dll, from PostGres 8.4, is in the path. If I build psycopg2 with a vc6-built python, it will
run fine. But the problem is that I need it to work with a vc9-built Python.
The page I referenced mentioned using an older version. When I try building version 2.12.0 (or even 2.10.0),
I get this error:
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -DPSYCOPG_DEFAULT_PYDATETIME=1 "-DPSYCOPG_VERSION=\"2.0.10 (dt d
ec ext pq3)\"" -DPG_VERSION_HEX=0x080401 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BO
OLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -IC:\Python26\include -IC:\Pytho
n26\PC -I. -Ic:/apps/POSTGR~1/8.4/include -Ic:/apps/POSTGR~1/8.4/include/server
/Tcpsycopg\connection_int.c /Fobuild\temp.win32-2.6\Release\psycopg\connection_i
nt.obj /Wp64
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release
connection_int.c
psycopg\connection_int.c(70) : error C2143: syntax error : missing ';' before 't
ype'
psycopg\connection_int.c(71) : error C2065: 'notice' : undeclared identifier
psycopg\connection_int.c(71) : warning C4047: '=' : 'int' differs in levels of i
ndirection from 'connectionObject_notice *'
psycopg\connection_int.c(73) : error C2065: 'notice' : undeclared identifier
psycopg\connection_int.c(73) : warning C4047: '!=' : 'int' differs in levels of
indirection from 'void *'
and on and on.... Looking at the C code, there is no conditional code
wrapping the definition of struct connectionObject_notice, so I don't
see what would trigger this error.
Finally, a poster in the above thread mentioned "PG6000". What is that?
- Eric
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许你应该安装 Windows SDK 7.0。
我的系统中安装了 vs2005/vs2008/vc2010 和一些 windows SDK,
当我安装 psycopg2-2.4.2 python 包时使用“python setup.py install”,
它提示我需要“mt.exe”;
所以我将“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin”添加到路径中,
然后就可以构建了。但是 python -c "import psycopg2" 仍然失败,所以我将 PostgreSQL 客户端安装路径:“...\PostgreSQL\8.4\bin” 添加到系统路径,然后一切运行正常。
maybe you should install windows SDK 7.0.
I have vs2005/vs2008/vc2010 and some windows SDK installed in my system,
and when I install psycopg2-2.4.2 python package use "python setup.py install",
it prompt me need "mt.exe";
so I add "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" to path,
then it will build ok. but python -c "import psycopg2" sill fail, so I add PostgreSQL client install path: "...\PostgreSQL\8.4\bin" to system path, then all runs fine.