我不得不对 AndiDog 的方法进行以下修改:
setup.py build -cmingw32
setup.py install --skip-build
如果没有 --skip-build 选项,安装将尝试再次构建并再次抱怨 MSVC:
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
此外,最初在使用 build 命令时,我遇到了很多这样的错误:
build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x1d): undefined reference to `_imp__PyImport_ImportModule'
build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x34): undefined reference to `_imp__PyObject_GetAttrString'
build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x53): undefined reference to `_imp__PyCObject_AsVoidPtr'
这是因为我最初安装的是 64 位版本的 Python 2.5.4 (python-2.5.4.amd64.msi)。我删除了它并安装了 32 位版本(python-2.5.4.msi)。这包括构建命令正在寻找的 libpython25.a 文件。