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

成功
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值