How to change python version for use with pyinstaller

Kyle Sargent picture Kyle Sargent · Apr 17, 2017 · Viewed 23.7k times · Source

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

print "Hello, World!"

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

pyinstaller hello.py

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?

Answer

Joseph D. picture Joseph D. · Mar 25, 2018

Using Python3:

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

PyInstaller==3.3.1

Then running the command:

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