本机环境:

  1、win7 64 旗舰版

  2、Qt 5.11.2(MSVC 2015,32 bit)

  3、到目前为止,python官方2018-10-20更新,Python 3.6.7;

1、下载合适的python版本,本机使用vs2015的Qt,所以选择了vs2015支持的3.6版本的python,

python3.7----vs2017
python3.6----vs2015
需要知道别的python版本,需要使用哪个VS编译,下载源码后,打开PCbuild/readme.text进行查看即可

2、解压后到D盘,目录结构

3、编译。

进入PCbuild目录,打开pcbuild.sln文件,右键python属性,选择你的编译配置(Debug还是Release,Win32还是X64)

 

编译解决方案时有可能会出错:windows sdk version 10.0.15063 was not found,解决方案是根据Fix python 3.6 build failure with VS 2015 and WinSDK!=10.0.15063所说的方法,打开python.props, 将第79行,

<DefaultWindowsSDKVersion>10.0.15063.0</DefaultWindowsSDKVersion>

更改为

<DefaultWindowsSDKVersion Condition="$(_RegistryVersion) == '10.0.15063'">10.0.15063.0</DefaultWindowsSDKVersion>

4、使用Release 32,Debug 32,编译成功python工程后(只需要编译Python这一个工程,其他的可以不编译),Python-3.6.7\PCbuild\win32 内会有32位的debug和Release库,目录结构如下:

5、至此python3.6.6编译成功

PYTHON_VERSION = 36
PYTHON_PATH = D:\Python-3.6.7\
PYTHON_LIB  = D:\Python-3.6.7\PCbuild\win32

 

参考资料:

『Python』VS2015编译源码注意事项https://www.cnblogs.com/hellcat/p/8742861.html

VS2015编译python 3.6.4源码https://blog.csdn.net/fitzzhang/article/details/79146107

posted on 2018-10-23 10:03  jsjrj01  阅读(1602)  评论(0编辑  收藏  举报