0

I need to make a python script into a standalone .exe file. I have tried to use py2exe using this compile code:

from distutils.core import setup
import py2exe

setup(console=['script.py'])

But all it does is spit out a folder with the exe file, as well as a bunch of other stuff. Problem is, I cannot run the exe file without it being in the same exact folder as the other files.

Is there a way to make a standalone .exe file that does not require any other files to run?

Richie378
  • 115
  • 1
  • 2
  • 10
  • have you looked at [this tutorial](http://www.py2exe.org/index.cgi/Tutorial) ? – mdodong May 16 '15 at 02:51
  • you can set `bundle_files=1` fore more details at http://www.py2exe.org/index.cgi/SingleFileExecutable – otterb May 28 '15 at 07:59
  • Possible duplicate of [py2exe - generate single executable file](http://stackoverflow.com/questions/112698/py2exe-generate-single-executable-file) – Cees Timmerman May 18 '17 at 14:39

2 Answers2

0

Use pyinstaller instead.

https://github.com/pyinstaller/pyinstaller/wiki

When you use it, make sure you use the --onefile option, this will pack all the libraries into a single .exe file. You may need to use one of the developing versions, as it is an old project.

-Robbie

Robbie Barrat
  • 510
  • 1
  • 6
  • 24
0

Yes, I would suggest the following for you:

from distutils.core import setup
import py2exe
import sys

__author__ = 'you'

sys.argv.append('py2exe')

setup(
    options={'py2exe': {
        'bundle_files': 1,
        'unbuffered': True,
        'compressed': True}},
    console=['script.py'],
    zipfile=None,
    )

This will create a single exe file, from the script that you can run from anywhere on your machine.

JamesD
  • 2,466
  • 24
  • 40