[Pythonmac-SIG] Yet another problem with path

Timothy Grant timothy.grant at gmail.com
Thu Aug 7 18:28:44 CEST 2008


On Thu, Aug 7, 2008 at 6:58 AM, Mike Covill <mcovill at mac.com> wrote:
>
> On 7-Aug-08, at 9:45 AM, Mike Covill wrote:
>
>> On 7-Aug-08, at 9:34 AM, Pascal Bompard wrote:
>>
>>> Returning to this 3 week old chestnut, (apologies for delay - my second
>>> child was born in the interim), and thanks to all who attempted to help, but
>>> I am still struggling with this issue.
>>>
>>>> Christopher Barker wrote:
>>>> If you have scripts you want to run from anywhere, make them executable:
>>>
>>> This is exactly what I need to occur with this particular script
>>>
>>>> chmod a+x MyScript.py
>>>
>>> permissions are set to 755 (i.e. full permissions)
>>>
>>>> and put:  #!usr/bin/env python   at the top.
>>>
>>> yes, that is in place
>>>
>>>> Then either:
>>>>
>>>> put them in a standard place that should be on your PATH, like:
>>>>
>>>> /usr/local/bin
>>>>
>>>> or put the path to your scripts in your PATH -- often people use:
>>>>
>>>> ~/bin
>>>
>>> I actually have this in my PATH,
>>> /Users/pascal/Documents/Python/Dev/myapp
>>>
>>> and with all the above I get:
>>>
>>> Administrator:~ 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
>>>
>>> whereas calling the script from within it's parent directory does work.
>>>
>>> What could I possibly be doing wrong here?
>>
>> Your PATH is only used to find the executable (python), not the document
>> (test.py).  The document must include either the relative path from where
>> you are, or the absolute path.
>
> You should be able to execute your script by typing just your script name
> from anywhere, leave out "python":
>
> Administrator:~ pascal$ test.py
>
> in this case test.py is the 'executable', and your system will look for it
> using your PATH setting.
>
> Mike
>
>>
>>>
>>>
>>>> do buy a book or surf the web for info about using the terminal on OS-X
>>>> -- it's a great skill to have.
>>>
>>> You're right. I have recently acquired a great book called "From Bash to
>>> Z-Shell", but it's tough to retain all the tricks when I use the terminal so
>>> seldom.

While command lines can be made to lie, it concerns me that it looks
like you're using and Administrator account to do all this work.
Administrators have far to much power and can do far too much damage
far too quickly. Especially if you're writing code that might
manipulate any files, I would strongly encourage you to use a regular
user account for doing your real work and only log in as an
administrator when required.

Of course if the command line was lying about the type of account
you're using completely ignore the previous paragraph.

-- 
Stand Fast,
tjg.  [Timothy Grant]


More information about the Pythonmac-SIG mailing list