Question

I wrote myself a small Python script that I want to use to automatically do things with certain types of files; as such, I want to create an .app out of it so that I can set certain files to be opened with it automatically.

So I looked around and found Platypus which seems to do what I need.

However, weirdly it doesn't work. Specifically, it does not seem to be finding the right python interpreter. I set it up as follows:

enter image description here

I.e., the script type is env so it should just read the top line of the file like the shell does.

In magic.py, the top line is #!/usr/bin/env python2.7.

Now, when I run the shell script on the command line (that is, ~/devel/magic.py whatever), everything works fine. But when I run the app, it errors with:

Traceback (most recent call last):
  File "/Users/jan/Dropbox/devel/Magic.app/Contents/Resources/script", line 8, in <module>
    from bencode import *
ImportError: No module named bencode

The same import works just fine when running it from the command line, so I'm thinking it's using the wrong interpreter somehow. How can I fix or debug this?

Was it helpful?

Solution

You are trying to import from bencode module but you didn't add it in the application's bundled resources. Either drag it to the list of included files and export again or just copy it to the resources folder in the package's contents.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top