2

I made a program in python which is in .py format. However, I would like it to be in .exe

The options I have found are: py2exe pyinstaller

The problems with those 2 are because I am running python 3.6 and those 2 programs do not support it, HELP!

ypranite
  • 103
  • 1
  • 1
  • 8

4 Answers4

2

Python 3.6 still isn't supported by Pyinstaller. So in order to use it you're gonna need Python 3.5 or below. So, you might wanna change your python version to 3.4 or 2.7. Then you can follow the procedure for creating the exe with pyinstaller. Also I think pyinstaller is a better option than py2exe.

However to make things work without switching to other versions, you might wanna try using cx_freeze:

1.Install the latest version of cx_freeze by pip install cx_Freeze.

2.Create a new python file named ‘setup.py’ on the current directory of your script.

3.On the setup.py, code this and save it:(here my prog.py refers to your .py file name)

from cx_Freeze import setup, Executable

base = None


executables = [Executable("my prog.py", base=base)]

packages = ["idna"]
options = {
    'build_exe': {

        'packages':packages,
    },

}

setup(
    name = "<any name>",
    options = options,
    version = "<any number>",
    description = '<any description>',
    executables = executables
)

4.With shift pressed right click on the same directory to open a command prompt window.

5.Type: python setup.py build.

6.Check the newly created folder ‘build‘. Within that folder you can able to find your application.

Dragon
  • 1,194
  • 17
  • 24
1
  • pyinstaller

    • pip install pyinstaller
    • Basic usage is very simple, just run it against your main script:
      • pyinstaller /path/to/yourscript.py
  • cx_Freeze

    • pip install cx-Freeze
  • auto-py-to-exe

    • pip install auto-py-to-exe
    • Then to run it, execute the following in the terminal:
      • auto-py-to-exe

enter image description here

Milovan Tomašević
  • 6,823
  • 1
  • 50
  • 42
0

With a simple google search, I found this question which gives a link to a version of py2exe which happens to support python 3.3 and up. Here is the link!

On that page you will find the following bit of information:

Py2exe is a distutils extension which allows to build standalone Windows executable programs (32-bit and 64-bit) from Python scripts; Python 3.3 and later are supported. It can build console executables, windows (GUI) executables, windows services, and DLL/EXE COM servers.

Notice:

Python 3.3 and later are supported.

C. Bird
  • 1
  • 4
0

I have created a batch file to do the work, but first, go to https://datatofish.com/add-python-to-windows-path/ and add python to your path.

Then create a new notepad file with this:

SET /P _input1= Enter the file directory: cd %_input1% SET /P _input2= Enter the file name: pyinstaller --onefile %_input2% ECHO The exe file is in the dict folder in %_input1% pause

Save this as a .bat file anywhere and run it. Enter the directory of the python script. then the name.

Hope this helps!

Wudfulstan
  • 129
  • 11