0

我正在尝试创建一个生成 exe 的 python 脚本。但我想让它运行,这样用户就不需要安装 python 来运行脚本。这是我的代码:(已使用 pyinstaller 转换为 exe)

import os

with open('output.py', 'w') as writeout:
     writeout.write('''
Hello world!
''')

# Creates pyinstaller by using cmd
os.system('cmd /c' + ' pyinstaller --onefile' + output + '.py')

所以我的代码基本上是一个生成exe的exe。但问题是用户需要安装 Python 才能运行这个 exe(原来的那个)。pyinstaller --onefile output.py由于所有这些代码都是在 cmd中写出的。我阅读了 pyinstaller 的文档,但没有发现任何有用的东西。

4

0 回答 0