如何更改 python 版本以与 pyinstaller 一起使用 [英] How to change python version for use with pyinstaller

查看:279
本文介绍了如何更改 python 版本以与 pyinstaller 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 .py 文件转换为 exe.我的文件 hello.py 内容如下:

I am trying to convert a .py file to an exe. My file, hello.py, reads:

print "Hello, World!"

我目前正在尝试使用 pyinstaller.但是当我运行命令时

I am currently trying to use pyinstaller. However when I run the command

pyinstaller hello.py

我收到错误消息元组索引超出范围",有人告诉我这意味着我的 Python 版本不受支持.特别是情况似乎是 pyinstaller 认为我正在尝试将 python 3.6 代码编译成一个 exe.但是我安装了 python 2.7 和 python 3.6.我如何让它知道我想让它把代码当作 python 2.7 代码?

I get the error message "tuple index out of range" which I have been told means my version of python is unsupported. In particular it would seem the situation is that pyinstaller thinks I am trying to compile python 3.6 code into an exe. But I have python 2.7 and python 3.6 installed. How do I let it know that I want it to regard the code as python 2.7 code?

推荐答案

使用Python3:

确保 PyInstaller 已安装在 Python 3.x 中:pip3 freeze

Make sure PyInstaller is installed in Python 3.x: pip3 freeze

PyInstaller==3.3.1

PyInstaller==3.3.1

然后运行命令:

/path/to/python3 -m PyInstaller your_script.py

这篇关于如何更改 python 版本以与 pyinstaller 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆