Executing Python Scripts on Mac using Python Launcher

Dave Angel d at davea.name
Tue Jun 26 14:32:53 EDT 2012


(You forgot to include the list on this message, but I'm including them
in my reply)

On 06/26/2012 02:07 PM, David Thomas wrote:
> 
> 
> On Tuesday, June 26, 2012 6:37:42 PM UTC+1, Dave Angel wrote:
>>
>> On 06/26/2012 01:19 PM, David Thomas wrote: 
>>> I have installed Python 2.7.3 from Python.org also in Terminal it states 
>> that I have 2.7.3. 
>>> How can I execute the script from Terminal?  I've tried typing python 
>> into the window and then dragging the file to terminal but I get a syntax 
>> error.  Sorry I am new to Python and just want to know how I can open such 
>> a file using 10.7. 
>>>
>>>
>>   <SNIP>
>>
> Thanks for the fast response how can I find out if Python is on the same 
> path as Terminal?
> 
> Is this located in the /usr Folder?
> 
> Thanks
> 

Looks like you're new to Unix as well.  (the following applies to Unix,
Linux, OS/X, and with modifications, to Windows)

Terminal is a program.

PATH is an environment variable.  You normally set it globally, but it's
sometimes modified by various scripts.  To see what it is in a given
Terminal session, simply issue the command:

echo $PATH

To see all your environment variables, use

printenv

Anyway, PATH is a list of directories that bash (or whatever shell
you're using) will search.  If you can run python with the simple command:

python

then it IS on your PATH.  That means that you do NOT want to cd to the
directory of python, but to the directory where your script is located.

cd  /fullpathtoscript                  (the location of your script)
python   myscript.py                (or whatever your script is called)


-- 

DaveA





More information about the Python-list mailing list