您的位置:首页 > 编程语言 > Python开发

win7下编译python源码

2015-08-10 10:58 615 查看

win7下编译python源码

下载源码:

打开网页:https://www.python.org/downloads/release/python-2710/



下载完成后解压即可

查看文档:

其实最最可利用的资源是官方的文档,我们进入到PCbuild目录下,打开readme.txt,这里介绍了如何编译python源码以及所需要的环境等。

his directory is used to build Python for Win32 and x64 platforms, e.g.

Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit

debug and release executables, Microsoft Visual C++ 2008 Express Edition is

required at the very least. In order to build 64-bit debug and release

executables, Visual Studio 2008 Standard Edition is required at the very

least. In order to build all of the above, as well as generate release builds

that make use of Profile Guided Optimisation (PG0), Visual Studio 2008

Professional Edition is required at the very least. The official Python

releases are built with this version of Visual Studio.

vs2008是所需的最低的版本,我们这里使用vs2012完全是可以的。

You can find build directories for older versions of Visual Studio and

Visual C++ in the PC directory. The legacy build directories are no longer

actively maintained and may not work out of the box.

PC/VC6/

Visual C++ 6.0

PC/VS7.1/

Visual Studio 2003 (7.1)

PC/VS8.0/

Visual Studio 2005 (8.0)

你也可以使用更早的版本来编译,这样的话你需要到PC目录下找到相对应的源码

配置环境:

使用vs2012打开PCbuild目录下的 sln文件:



打开项目的属性,找到配置那一项,只选择python和pythoncore:



找到下图这两个文件,依次单独编译(选中——>右键 仅用于项目 ——>仅重新生成 ):



编译运行:

最后在总工程上右键选择生成解决方案就可以编译成功了。在当然目录下会生成一些文件,如图:



我们从控制台进入当前目录运行python_d.exe就可以了,如图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: