Windows下编译Python模块源代码

一直都在Linux下工作,今天想在windows安装一个python模块,发生如下问题:
E:\Download\python\python-cjson-1.0.3>python setup.py install
running install
running build
running build_ext
building 'cjson' extension
error: Python was built with Visual Studio version 7.1, and extensions need to b
e built with the same version of the compiler, but it isn't installed.

google下发现一个解决方案:
I found an Alternate Solution by configuring MingW
Task:
RDFLib installation
Problem:   
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.
Solution:
How to Configure Mingw:
* Download last release from http://prdownloads.sourceforge.net/mingw  (MinGW-5.1.3.exe)
* Run the file to start the installation process
* Keep all values at their defaults and select at least next components:
           o MinGW base tools
           o g++ compiler
           o MinGW Make
* Add the C:\mingw\bin directory to the system PATH
* Create (or edit) a .cfg file for distutils (distutils.cfg) eg: C:\Python25\Lib\distutils\distutils.cfg with this content:
[build]
compiler=mingw32
[build_ext]
compiler=mingw32

Then type in your RDFlib directory> python setup.py install
creating C:\Python25\Lib\site-packages\rdflib\store
copying build\lib.win32-2.5\rdflib\store\AbstractSQLStore.py -> C:\Python25\Lib\
site-packages\rdflib\store
copying build\lib.win32-2.5\rdflib\store\AuditableStorage.py -> C:\Python25\Lib\
site-packages\rdflib\store
copying build\lib.win32-2.5\rdflib\store\Concurrent.py -> C:\Python25\Lib\site-p
ackages\rdflib\store
....
....
....
Writing C:\Python25\Lib\site-packages\rdflib-2.3.3-py2.5.egg-info
Thats it Good Luck!
Further Source:  http://livingpyxml.python-hosting.com/wiki/AmaraWindowsInstallTips
试试看

E:\Download\python\python-cjson-1.0.3>python setup.py install
running install
running build
running build_ext
building 'cjson' extension
D:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -ID:\Python25\include -ID:\Pytho
n25\PC -c cjson.c -o build\temp.win32-2.5\Release\cjson.o
writing build\temp.win32-2.5\Release\cjson.def
creating build\lib.win32-2.5
D:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.5\Release\cjson.o
build\temp.win32-2.5\Release\cjson.def -LD:\Python25\libs -LD:\Python25\PCBuild
-lpython25 -lmsvcr71 -o build\lib.win32-2.5\cjson.pyd
running install_lib
copying build\lib.win32-2.5\cjson.pyd -> D:\Python25\Lib\site-packages
running install_egg_info
Writing D:\Python25\Lib\site-packages\python_cjson-1.0.3-py2.5.egg-info

成功

你可能感兴趣的:(C++,windows,python,ext,C#)