0

First of all, I know about things like Py2Exe, and I've tried it, didn't work out for me. If I use a .bat to run a .py/.pyw file on a computer without the files for Python, will it still work? If not, a tutorial on how to use Py2exe would be nice.

Notes: I've tried to learn Java because lots of computers have it, but it's just too hard for me right now I don't fully know Python, but I know my way around a basic program I would be willing to try out another language if it's easier that way, but nothing harder than Java, because I struggle with Java.

6
  • 2
    By any computer I'm assuming you meant any PC running Windows? Commented Mar 23, 2013 at 20:45
  • The Py2EXE tutorial is not very hard to find... Commented Mar 23, 2013 at 20:47
  • Yeah, any computer that can run an .exe is the very least I want Commented Mar 23, 2013 at 21:00
  • @MattDMo: Yeah, but I figured since I was here I'd ask Commented Mar 23, 2013 at 21:01
  • There is no way for it run on every computer. If you distribute the actual python files, you can run it on most machines, but will require the user to install python first. Py2exe will only run on Windows, and possibly using Mono under Linux. Commented Mar 23, 2013 at 21:02

1 Answer 1

1

You already have complete tutorials shipped with Py2exe that you can use for your application.

The samples are located under Python\Lib\site-packages\py2exe\samples.

As a quick example this is the setup.py I use in my application to create a single executable with all the required libraries embedded, but keep in mind that any data files e.g. picture, sound, textfile etc will need to be bundled with the executable.

from distutils.core import setup
import py2exe
import sys

if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")

class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        self.version = "0.0.0"
        self.company_name = "Mr.Pyo-Pyo Company"
        self.copyright = "o_O"
        self.name = "Mr.Puyo-Puyo"

test_wx = Target(
    description = "Mr.Puyo-Puyo",
    script = "main.py", # Modify this to use your main .py file
    dest_base = "Mr.Puyo-Puyo")

setup(
    options = {"py2exe": {"compressed": 1,
                          "optimize": 2,
                          "ascii": 1,
                          "bundle_files": 1}},
    zipfile = None,
    windows = [test_wx],
    )

Running the setup script is as simple as running the script inside your applications directory, and it will create the the executable inside a folder called dist.

If you are running into any errors, you probably need to install the Microsoft Visual C++ 2008 Redistributable Package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.