把python文件转为exe可执行文件

首先安装 PyInstaller 工具,使用以下命令安装:

先打开命令框:win+R  输入cmd

pip install pyinstaller    #安装 PyInstaller 工具,使用以下命令安装:

然后使用以下命令将其转换成 Windows 平台下的可执行文件(exe):

pyinstaller --onefile 文件名.py

若执行pyinstaller --onefile love.py时候遇到报错:The 'typing' package is an obsolete backport of a standard library package and is incompatible with PyInstaller. Please `conda remove typing` then try again.

这是因为 PyInstaller 不支持 typing 库,而该库已经成为 Python 的标准库之一,为了避免上述错误,您可以在执行 pyinstaller 命令前,执行以下命令卸载 typing 库:

pip uninstall typing

然后重新执行 pyinstaller 命令即可。

把python文件转为exe可执行文件_第1张图片

在dist文件夹里 可以找到exe文件

你可能感兴趣的:(python,开发语言)