Python 编译为exe

1、安装pyInstaller

pip install pyinstaller

成功后显示successfully…
在这里插入图片描述
2 、进入py文件目录
3 、 pyinstaller.py -F 文件.py
4 、生产exe在dist中

具体例子
1、Cd C:\Users\Administrator\Desktop\c2p\ConsoleApplication1

在这里插入图片描述
2、pyinstaller.py -F great_module.py
在这里插入图片描述
module.py 如下
在这里插入图片描述

3、进入dist有exe
在这里插入图片描述
在这里插入图片描述
4、运行 进入dist 运行exe
在这里插入图片描述

5、在C++中运行
#include “stdafx.h”
//#include
//#include <Python.h>
#include <stdlib.h> //system(“pause”); 暂停,按键继续
//#include <Windows.h>

int main(int argc, _TCHAR* argv[])
{
WinExec(“C:\Users\Desktop\c2p\ConsoleApplication1\dist\great_module.exe”, SW_SHOWNORMAL);//win下‘\’
system(“pause”);
return 0;
}

发布了13 篇原创文章 · 获赞 7 · 访问量 4339

猜你喜欢

转载自blog.csdn.net/qq_29230349/article/details/88903209