4

I have a program that I can run as

> python transactions.py file.csv

That processes the provided CSV file.

I want to compile it to an executable so my friends can use it without having to install all the packages it requres.

py2app compiles the app, and in 'Alias' mode I'm able to successfully run the application

> ./dist/transactions.app/Contents/MacOS/transactions.csv

However when I complete the actual compilation and have a /dist/transactions.app/ directory created, whenever I try to run

> open /dist/transactions.app file.csv

the program fails with

> 1/29/15 1:05:11.190 PM transactions[25848]:     txn_csv = sys.argv[1]
> 1/29/15 1:05:11.190 PM transactions[25848]: IndexError: list index out of range

right after the line in my program that sets a variable equal to sys.argv[1]

What am I doing wrong, and how can I run this program with input from a CLI argument at sys.argv[1] ?

Tyler Wood
  • 1,947
  • 2
  • 19
  • 29

1 Answers1

2

EDIT:

You are using open wrong.

The correct command to launch your app would be:

open /dist/transactions.app --args file.csv
jgritty
  • 11,660
  • 3
  • 38
  • 60
  • The py2applet script that generated setup.py for me did set OPTIONS = {'argv_emulation': True} – Tyler Wood Jan 29 '15 at 22:37
  • Thanks @jgritty , the app runs now! Now I just need to figure out how to do something with the output which goes to "console" and doesn't get printed out to terminal. – Tyler Wood Jan 30 '15 at 20:26