可以使用pyinstaller工具来打包Python代码为可执行文件。
要使用pyinstaller,首先需要使用pip安装它:
pipinstall pyinstaller
然后,可以在命令行中运行以下命令来打包Python代码:
pyinstaller<python_script.py>
这将在当前目录中生成一个“dist”文件夹,其中包含可执行文件。
您还可以使用“--onefile”选项来将所有文件打包到单个可执行文件中:
pyinstaller--onefile <python_script.py>
您还可以使用“--name”选项指定可执行文件的名称:
pyinstaller --onefile --name<executable_name> <python_script.py>
有关pyinstaller的更多选项和用法,请参阅它的文档:https://pyinstaller.readthedocs.io/en/stable/