Princess Magnificent February 2016

py2exe and setting up to get its target from argv?

I'm trying to create an executable from a .py file, and if I do things exactly as the py2exe tutorial says, it works. I put setup(console=[""]) in my file, then type python py2exe into my console, and it works.

BUT. This means that whenever I want to make another python file into an executable, I have to go open and edit And I'd rather do something else:

from distutils.core import setup
from sys import argv
import py2exe

##This was originally setup(console=[""]) and it DOES work that way

And then type in python py2exe. On account of it being invalid command name ''

I've also tried it by changing the order, making it python py2exe and changing the argv[1] to argv[2]. I get the exact same error message.

I mean, I DO have a functioning way to make my .py files into .exe files, but I'm really annoyed that something that seems like it ought to be such a simple change is't working. What am I missing here?


g.d.d.c February 2016

You're running into trouble because setup is using sys.argv. If you change your call to setup(console = [sys.argv.pop(1)] I believe you will stop stepping on distutils' toes and things should go smoothly.

Post Status

Asked in February 2016
Viewed 2,864 times
Voted 11
Answered 1 times


Leave an answer