[Pythonmac-SIG] Yet another problem with path

Pascal Bompard pascal.bompard at gmail.com
Mon Jul 14 03:41:35 CEST 2008


Yes, I am aware that I could do that. I chose to only demonstrate the  
full path method rather than both ways to access the file in my example.

The problem remains though, that every time I want to run a script in  
that directory, I'd have to type out the entire path, which is not  
ideal.

Surely there must be a work around to allow me to only type in the  
script name, at least I assume there must be?


> If you are not including the full path to your Python script, then  
> you need to change the working directory in Terminal to be the same  
> as the script.
>
> Try this command:
>
> cd /Users/pascal/Documents/Python/Dev/myapps
> python test.py

>> I will include some terminal output below to help with diagnostics:
>> Successful attempt:
>> ----------------------------------------
>> pascal$ python /Users/pascal/Documents/Python/Dev/myapps/test.py
>> Unsuccessful attempt:
>> ----------------------------------------
>> pascal$ python test.py
>> /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/ 
>> Python.app/Contents/MacOS/Python: can't open file 'test.py': [Errno  
>> 2] No such file or directory
>


More information about the Pythonmac-SIG mailing list