建筑C->;64位操作系统上的Python库
我有一个用Swig打包的第三方库,这样我就可以用Python与它对话。这适用于32位OS/Python/第三方LIB。最近,我从第三方收到了这些库的64位版本,因此我想重建这些库以利用这一点(当然,使用64位Python和64位操作系统)。但是,我在尝试导入库时遇到以下错误:建筑C->;64位操作系统上的Python库,python,visual-studio,64-bit,swig,32-bit,Python,Visual Studio,64 Bit,Swig,32 Bit,我有一个用Swig打包的第三方库,这样我就可以用Python与它对话。这适用于32位OS/Python/第三方LIB。最近,我从第三方收到了这些库的64位版本,因此我想重建这些库以利用这一点(当然,使用64位Python和64位操作系统)。但是,我在尝试导入库时遇到以下错误: Traceback (most recent call last): File "camera.py", line 1, in <module> import memhandler File "
Traceback (most recent call last):
File "camera.py", line 1, in <module>
import memhandler
File "C:\neo\memhandler.py", line 26, in <module>
_memhandler = swig_import_helper()
File "C:\neo\memhandler.py", line 22, in swig_import_helper
_mod = imp.load_module('_memhandler', fp, pathname, description)
ImportError: DLL load failed: %1 is not a valid Win32 application.
有什么想法吗?我唯一能想到的是,我实际上没有64位库;我不知道如何判断DLL/LIB文件是64位还是32位 dumpbin/headers将告诉您DLL是32位还是64位。好的,运行atcorem.lib的dumpbin/headers会在顶部显示:“8664机器(x64)”。看起来它们是真正的64位。这个假设到此为止。是不是_memhandler.pyd依赖于另一个DLL,例如来自Andor SDK的DLL,而路径中有该DLL的32位版本?就是这样!修复了我用来运行程序的批处理文件中的路径,现在可以运行了。我认真地认为这不是一个可能的问题,因为我认为64位操作系统是干净的;我想我们把它弄得一团糟,留下了一些旧文件。非常感谢!
PYROOT = C:\Python27x64
PYINCLUDE = /I$(PYROOT)\include /I$(PYROOT)\Lib\site-packages\numpy\core\include
PYLIBS = /LIBPATH:$(PYROOT)\libs python27.lib
ANDORLIBS = "Andor SDK3\atcorem.lib"
LIBS = $(PYLIBS) $(ANDORLIBS)
CXXFLAGS = /MD /EHsc /DWIN32 /D_WINDOWS /DNOPCH /O2 $(PYINCLUDE)
# We have two separate SWIG libraries to build here; one calls most of the
# Andor functions; the other does some intermediary work for us before
# calling certain special Andor functions. We also have to compile the
# intermediary library ourselves.
ANDOROBJS = neo_wrap.obj
WRAPOBJS = memhandler.obj
WRAPSWIGOBJS = memhandler_wrap.obj
ANDORTARGET = _neo.pyd
WRAPTARGET = _memhandler.pyd
all: $(ANDORTARGET) $(WRAPTARGET)
$(ANDORTARGET): $(ANDOROBJS)
link /dll /DEBUG /NOLOGO /out:$@ /SUBSYSTEM:WINDOWS $(ANDOROBJS) $(LIBS)
$(WRAPTARGET): $(WRAPOBJS) $(WRAPSWIGOBJS)
link /dll /DEBUG /NOLOGO /out:$@ /SUBSYSTEM:WINDOWS $(WRAPOBJS) $(LIBS)
link /dll /DEBUG /NOLOGO /out:$@ /SUBSYSTEM:WINDOWS $(WRAPSWIGOBJS) $(LIBS) memhandler.obj
swig:
C:\swigwin-2.0.4\swig.exe -c++ -python neo.i
C:\swigwin-2.0.4\swig.exe -c++ -python memhandler.i
clean:
del *ilk *lib *pdb *obj *exp *wrap.cxx *pyd *pyd.manifest