1

I've a simple python script that I want to see it as an exe file so I can run it in any computer.

My friend told me about py2exe. But, when I searched it, I found that it's limited to python 2.X . I wrote my script in 3.X python (3.4 , the last realese till the moment).

I wonder, How can I convert 3.x python scripts into excutable exe files?

Any sugesstions?

Fawzy Hegab
  • 137
  • 1
  • 2
  • 7
  • Does this answer your question? [How can I convert a .py to .exe for Python?](https://stackoverflow.com/questions/41570359/how-can-i-convert-a-py-to-exe-for-python) – Gino Mempin Jan 22 '23 at 07:06

2 Answers2

3

you can try cx_Freeze!

This module supports python3.x well.

PaleNeutron
  • 2,543
  • 4
  • 25
  • 43
  • Is this a module in python like random or math? (I', new to programming so excuse me if I ask dull questions) – Fawzy Hegab Aug 28 '14 at 02:42
  • @MathsLover no, it is not a built-in module, you have to install it yourself by run `pip install cx_freeze` in your commandline. – PaleNeutron Aug 28 '14 at 02:53
  • I've download the file from the site. I wrote the command you typed in the interpreter, it gives error. Could you provide me with the steps please? – Fawzy Hegab Aug 28 '14 at 03:00
  • @MathsLover specific your python version and system platform in your question. DO NOT execute the command in python, but in your system cmd/terminal instead. – PaleNeutron Aug 28 '14 at 03:02
  • I excuted it in the cmd and gave me "syntaxerror: invalid syntax". – Fawzy Hegab Aug 28 '14 at 03:08
  • @MathsLover ╮(╯_╰)╭...that's amazing! `syntaxerror: invalid syntax `shows with python repr not your cmd. Exit python and execute the command. – PaleNeutron Aug 28 '14 at 03:22
  • I exited python. I wrote it in cmd and it still gives me the same error syntax message. if you don't believe it, I can show you a print screen If you want. – Fawzy Hegab Aug 28 '14 at 03:30
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60132/discussion-between-paleneutron-and-maths-lover). – PaleNeutron Aug 28 '14 at 03:38
1

Try using the "pyinstaller" module. The steps below will tell you how to install and use it:

Get the command prompt up and ready

  1. Install the pyinstaller module (write this in the command prompt):

    pip install pyinstaller

  2. Change the directory to the folder that has the Python script(write in cmd too):

    cd The\directory\of\your\code

  3. Convert the file(still in the cmd)

    pyinstaller --onefile nameOfYourScript.py

The EXE file will be in the dist folder

PLEASE NOTE: You must have Python added to path otherwise this won't work.

AngusAU293
  • 19
  • 7