[Tutor] [OSX] "Executable" .py or pyc script (stuck at Applescript)

Rich Lovely roadierich at googlemail.com
Thu Nov 10 16:33:37 CET 2011


On 10 Nov 2011, at 15:20, learner404 wrote:

> 
> 
> On Thu, Nov 10, 2011 at 2:14 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> learner404 wrote:
> Hello list!
> 
> - myapp.py is in a "myfolder" folder that the "users" will be able to
> download and put anywhere on their Mac.
> [...]
> 
> In both cases OSX complains it can't find the file. 
> 
> Do you mean that AppleScript can't find the file, or that Python can't find the file?
> 
> When I double click on the AppleScript the terminal opens with
> 
> $ python myapp.py
> $ python: can't open file 'avcOsxLinux.py': [Errno 2] No such file or directory
>  
> myapp.py and the AppleScript are both in the same directory. If I open manually a shell in this directory "python myapp.py" works.
> 
> It all seems like the Python invoked in the AppleScript have his current directory in root (and not the folder where i'm executing the AppleScript). I don't see how I can change this from the AppleScript or simply find a general solution to execute a .py script on Mac within the constrains I mentioned above. 
> 
> 
> Please don't summarize or paraphrase errors. Please copy and paste the EXACT error message that is shown.
> 
> If this is a problem with AppleScript being unable to find the file, you will be better off asking on an AppleScript mailing list.
> 
> In general, on Unix-like systems (and that includes Mac OS X), you can't expect a command like:
> 
> python myapp.py
> 
> to work unless myapp.py is in the current directory.
> 
> 
> 
> -- 
> Steven
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

It looks like your script is being found fine, meaning the problem lies elsewhere - unless your actual app is called "avcOsxLinux.py, and you missed renaming it in the error message.  Try adding a print statement as the very first line - before any imports - to test this.

The only reference to that filename is a french audio-visual library, which might not be installed on your target system.

Rich "RoadieRich" Lovely

There are 10 types of people in the world:
Those who know binary,
Those who do not,
And those who are off by one.



More information about the Tutor mailing list