Kyl*_*ent 7 python pyinstaller python-2.7
我想将.py文件转换为exe.我的文件hello.py读取:
print "Hello, World!"
Run Code Online (Sandbox Code Playgroud)
我目前正在尝试使用pyinstaller.但是当我运行命令时
pyinstaller hello.py
Run Code Online (Sandbox Code Playgroud)
我收到错误消息"元组索引超出范围",我被告知这意味着我的python版本不受支持.特别是情况似乎是pyinstaller认为我正在尝试将python 3.6代码编译成exe.但是我安装了python 2.7和python 3.6.我如何让它知道我希望它将代码视为python 2.7代码?
Jos*_* D. 11
使用Python3:
确保PyInstaller安装在Python 3.x中:pip3 freeze
PyInstaller == 3.3.1
然后运行命令:
/path/to/python3 -m PyInstaller your_script.py
Run Code Online (Sandbox Code Playgroud)
如果之前没有安装,首先在你的 python2.7 版本中安装 Pyinstaller
py -2 -m pip install pyinstaller
然后转到您的文件夹和
py -2 -m pyinstaller -F filename.py
Run Code Online (Sandbox Code Playgroud)
假设你python 2.x在下面的路径上python2可以做
python2 -m pyinstaller hello.py
Run Code Online (Sandbox Code Playgroud)