Can I get psycopg2 to work on Windows with a python built with vc9?
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 fa开发者_运维百科iled: 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
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.
精彩评论