Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24437 > unrolled thread

Executing Python Scripts on Mac using Python Launcher

Started byDavid Thomas <dthomas86@me.com>
First post2012-06-25 11:19 -0700
Last post2012-06-27 23:33 +0200
Articles 20 on this page of 22 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-25 11:19 -0700
    Re: Executing Python Scripts on Mac using Python Launcher Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-06-25 12:49 -0700
      Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-26 10:19 -0700
        Re: Executing Python Scripts on Mac using Python Launcher Dave Angel <d@davea.name> - 2012-06-26 13:37 -0400
          Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-26 11:09 -0700
          Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-26 11:09 -0700
          Re: Executing Python Scripts on Mac using Python Launcher Dave Angel <d@davea.name> - 2012-06-26 14:32 -0400
        Re: Executing Python Scripts on Mac using Python Launcher Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-06-26 11:56 -0700
        Re: Executing Python Scripts on Mac using Python Launcher Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-06-26 15:51 -0400
          Re: Executing Python Scripts on Mac using Python Launcher Hans Mulder <hansmu@xs4all.nl> - 2012-06-26 22:12 +0200
            Re: Executing Python Scripts on Mac using Python Launcher Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-06-26 18:35 -0400
            Re: Executing Python Scripts on Mac using Python Launcher Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-06-27 00:13 +0100
      Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-26 10:19 -0700
    Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-26 11:11 -0700
      Re: Executing Python Scripts on Mac using Python Launcher Hans Mulder <hansmu@xs4all.nl> - 2012-06-26 21:16 +0200
        Re: Executing Python Scripts on Mac using Python Launcher Dave Angel <d@davea.name> - 2012-06-26 16:41 -0400
          Re: Executing Python Scripts on Mac using Python Launcher Hans Mulder <hansmu@xs4all.nl> - 2012-06-26 23:48 +0200
            Re: Executing Python Scripts on Mac using Python Launcher Dave Angel <d@davea.name> - 2012-06-26 22:38 -0400
            Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-27 10:05 -0700
              Re: Executing Python Scripts on Mac using Python Launcher Hans Mulder <hansmu@xs4all.nl> - 2012-06-27 20:29 +0200
                Re: Executing Python Scripts on Mac using Python Launcher David Thomas <dthomas86@me.com> - 2012-06-27 13:45 -0700
                  Re: Executing Python Scripts on Mac using Python Launcher Hans Mulder <hansmu@xs4all.nl> - 2012-06-27 23:33 +0200

Page 1 of 2  [1] 2  Next page →


#24437 — Executing Python Scripts on Mac using Python Launcher

FromDavid Thomas <dthomas86@me.com>
Date2012-06-25 11:19 -0700
SubjectExecuting Python Scripts on Mac using Python Launcher
Message-ID<8b352333-23b5-4cfb-843d-29ffe1ef0905@googlegroups.com>
Hello,
This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
 How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.

Thanks

[toc] | [next] | [standalone]


#24440

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2012-06-25 12:49 -0700
Message-ID<mailman.1494.1340653759.4697.python-list@python.org>
In reply to#24437
On Mon, Jun 25, 2012 at 11:19 AM, David Thomas <dthomas86@me.com> wrote:
> Hello,
> This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
>  How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.
>
> Thanks
> --

You can't find the upload feature because this isn't a Google Group.
It's a Usenet newsgroup that Google Groups provides access to that's
also available as a mailing list. If you want to provide an image, use
an image host and link to the image.

As to your question, I have a few questions of my own. What version of
Python are you using? Is it the version included in Mac OS X,
installed from a python.org binary, compiled by source, or installed
through a package manager? What happens if you call the script from
the command line instead of using the Launcher application?

[toc] | [prev] | [next] | [standalone]


#24469

FromDavid Thomas <dthomas86@me.com>
Date2012-06-26 10:19 -0700
Message-ID<347d6190-1bfc-4117-85ff-4abaa0966710@googlegroups.com>
In reply to#24440
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.

Thanks

http://www.freeimagehosting.net/ilbqt
http://www.freeimagehosting.net/r5ars
On Monday, June 25, 2012 8:49:07 PM UTC+1, Benjamin Kaplan wrote:
> On Mon, Jun 25, 2012 at 11:19 AM, David Thomas <dthomas86@me.com> wrote:
> > Hello,
> > This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
> >  How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.
> >
> > Thanks
> > --
> 
> You can't find the upload feature because this isn't a Google Group.
> It's a Usenet newsgroup that Google Groups provides access to that's
> also available as a mailing list. If you want to provide an image, use
> an image host and link to the image.
> 
> As to your question, I have a few questions of my own. What version of
> Python are you using? Is it the version included in Mac OS X,
> installed from a python.org binary, compiled by source, or installed
> through a package manager? What happens if you call the script from
> the command line instead of using the Launcher application?

[toc] | [prev] | [next] | [standalone]


#24473

FromDave Angel <d@davea.name>
Date2012-06-26 13:37 -0400
Message-ID<mailman.1522.1340732297.4697.python-list@python.org>
In reply to#24469
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.
>
> Thanks

Assuming python is on your PATH within that terminal, you'd normally do
something like:

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


If that doesn't work for you, please be specific about what happens. 
Best way to do that is to copy/paste the text (showing in terminal) 
into your reply here.

Also, please don't top-post.  Put your new text AFTER the part you've
quoted from earlier messages.

-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#24474

FromDavid Thomas <dthomas86@me.com>
Date2012-06-26 11:09 -0700
Message-ID<mailman.1523.1340734197.4697.python-list@python.org>
In reply to#24473
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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA

Hi 

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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA

[toc] | [prev] | [next] | [standalone]


#24475

FromDavid Thomas <dthomas86@me.com>
Date2012-06-26 11:09 -0700
Message-ID<5d9bb673-0e93-4fcc-a21b-e56f2aa2bb0f@googlegroups.com>
In reply to#24473
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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA

Hi 

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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA



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.
> >
> > Thanks
> 
> Assuming python is on your PATH within that terminal, you'd normally do
> something like:
> 
> cd  /fullpathtoscript                  (the location of your script)
> python   myscript.py                (or whatever your script is called)
> 
> 
> If that doesn't work for you, please be specific about what happens. 
> Best way to do that is to copy/paste the text (showing in terminal) 
> into your reply here.
> 
> Also, please don't top-post.  Put your new text AFTER the part you've
> quoted from earlier messages.
> 
> -- 
> 
> DaveA

[toc] | [prev] | [next] | [standalone]


#24476

FromDave Angel <d@davea.name>
Date2012-06-26 14:32 -0400
Message-ID<mailman.1524.1340735602.4697.python-list@python.org>
In reply to#24473
(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

[toc] | [prev] | [next] | [standalone]


#24478

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2012-06-26 11:56 -0700
Message-ID<mailman.1525.1340736999.4697.python-list@python.org>
In reply to#24469
On Tue, Jun 26, 2012 at 10:19 AM, David Thomas <dthomas86@me.com> 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.
>
> Thanks
>
> http://www.freeimagehosting.net/ilbqt
> http://www.freeimagehosting.net/r5ars

My guess would be that you're getting a SyntaxError when you run it
through the Launcher too. WIthout seeing the script, I don't know why
that would is.

I can tell you one thing you're doing wrong. Never, ever, use input()
in Python 2. If you do, all someone has to do is type in
__import__('os').remove(__file__) and stuff starts getting deleted.
"input" interprets what it reads in. Use raw_input() instead, which
always returns a string.

[toc] | [prev] | [next] | [standalone]


#24480

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-06-26 15:51 -0400
Message-ID<mailman.1526.1340740315.4697.python-list@python.org>
In reply to#24469
On Tue, 26 Jun 2012 10:19:45 -0700 (PDT), David Thomas
<dthomas86@me.com> declaimed the following in gmane.comp.python.general:


> http://www.freeimagehosting.net/ilbqt

	That's an interesting configuration...

	"pythonw.exe" is a version of the Python interpreter designed to NOT
OPEN a console -- so you've got a configuration saying "open a console
to run a no-console interpreter".

	Normally pythonw.exe is used with scripts having .pyw extension;
these are scripts that use tkinter, wxPython, or other GUI system to
create a graphical environment and don't want a console (terminal)
window cluttering the screen when they don't use text I/O.

	Console based programs (.py) should be run using python.exe; adjust
your settings.

> http://www.freeimagehosting.net/r5ars

	And this is to be expected... In Python 2.x, "input()" attempts to
evaluate the input data, and you didn't supply anything -- hence EOF.
For your usage, you want "raw_input()", which just grabs the next line
of text and returns it as a string.


	As for how to run if you've opened a console (shell [bash]) window,
the way to run a script is to type

	python <path/name/to/your/script>.py <any command line arguments>


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#24482

FromHans Mulder <hansmu@xs4all.nl>
Date2012-06-26 22:12 +0200
Message-ID<4fea17c6$0$6940$e4fe514c@news2.news.xs4all.nl>
In reply to#24480
On 26/06/12 21:51:41, Dennis Lee Bieber wrote:
> On Tue, 26 Jun 2012 10:19:45 -0700 (PDT), David Thomas
> <dthomas86@me.com> declaimed the following in gmane.comp.python.general:
> 
> 
>> http://www.freeimagehosting.net/ilbqt
> 
> 	That's an interesting configuration...
> 
> 	"pythonw.exe" is a version of the Python interpreter designed to NOT
> OPEN a console -- so you've got a configuration saying "open a console
> to run a no-console interpreter".

That's on Windows; on the Mac python and pythonw are identical.
In fact, they're hard links to the same file.

> 	Normally pythonw.exe is used with scripts having .pyw extension;
> these are scripts that use tkinter, wxPython, or other GUI system to
> create a graphical environment and don't want a console (terminal)
> window cluttering the screen when they don't use text I/O.
> 
> 	Console based programs (.py) should be run using python.exe; adjust
> your settings.

That shouldn't matter on a Mac.

You may want to check "allow #! to override", though.

I mean, if there is a #! in a file pointing to a specific version of
python, then it's probably there for a reason.  For example, the script
might use a third party module installed only in that Python install.

>> http://www.freeimagehosting.net/r5ars
> 
> 	And this is to be expected... In Python 2.x, "input()" attempts to
> evaluate the input data, and you didn't supply anything -- hence EOF.
> For your usage, you want "raw_input()", which just grabs the next line
> of text and returns it as a string.

What he says.

> 	As for how to run if you've opened a console (shell [bash]) window,
> the way to run a script is to type
> 
> 	python <path/name/to/your/script>.py <any command line arguments>


Hope this helps,

-- HansM


[toc] | [prev] | [next] | [standalone]


#24490

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-06-26 18:35 -0400
Message-ID<mailman.1533.1340751059.4697.python-list@python.org>
In reply to#24482
On Tue, 26 Jun 2012 22:12:54 +0200, Hans Mulder <hansmu@xs4all.nl>
declaimed the following in gmane.comp.python.general:

> On 26/06/12 21:51:41, Dennis Lee Bieber wrote:
> > On Tue, 26 Jun 2012 10:19:45 -0700 (PDT), David Thomas
> > <dthomas86@me.com> declaimed the following in gmane.comp.python.general:
> > 
> > 
> >> http://www.freeimagehosting.net/ilbqt
> > 
> > 	That's an interesting configuration...
> > 
> > 	"pythonw.exe" is a version of the Python interpreter designed to NOT
> > OPEN a console -- so you've got a configuration saying "open a console
> > to run a no-console interpreter".
> 
> That's on Windows; on the Mac python and pythonw are identical.
> In fact, they're hard links to the same file.

	Okay, but...

	It may still be cleaner (to non-Mac users) if the execution
preferences still kept the "use terminal" to the python.exe, and left
"pythonw.exe" to "no terminal" applications <G>

	Even if the same executable is used in the end...

> 
> You may want to check "allow #! to override", though.
> 
> I mean, if there is a #! in a file pointing to a specific version of
> python, then it's probably there for a reason.  For example, the script
> might use a third party module installed only in that Python install.
>
	While I knew what that option meant, I didn't mention it myself as
the OP probably (based on the nature of the questions) wouldn't
understand the meaning... (And, on Windows at least, #! lines don't do
anything <G>)
 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#24491

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-06-27 00:13 +0100
Message-ID<mailman.1534.1340752347.4697.python-list@python.org>
In reply to#24482
On 26/06/2012 23:35, Dennis Lee Bieber wrote:
>
> (And, on Windows at least, #! lines don't do
> anything<G>)
>

New for Python 3.3 http://www.python.org/dev/peps/pep-0397/

-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


#24470

FromDavid Thomas <dthomas86@me.com>
Date2012-06-26 10:19 -0700
Message-ID<mailman.1520.1340731189.4697.python-list@python.org>
In reply to#24440
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.

Thanks

http://www.freeimagehosting.net/ilbqt
http://www.freeimagehosting.net/r5ars
On Monday, June 25, 2012 8:49:07 PM UTC+1, Benjamin Kaplan wrote:
> On Mon, Jun 25, 2012 at 11:19 AM, David Thomas <dthomas86@me.com> wrote:
> > Hello,
> > This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
> >  How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.
> >
> > Thanks
> > --
> 
> You can't find the upload feature because this isn't a Google Group.
> It's a Usenet newsgroup that Google Groups provides access to that's
> also available as a mailing list. If you want to provide an image, use
> an image host and link to the image.
> 
> As to your question, I have a few questions of my own. What version of
> Python are you using? Is it the version included in Mac OS X,
> installed from a python.org binary, compiled by source, or installed
> through a package manager? What happens if you call the script from
> the command line instead of using the Launcher application?

[toc] | [prev] | [next] | [standalone]


#24477

FromDavid Thomas <dthomas86@me.com>
Date2012-06-26 11:11 -0700
Message-ID<ee3e6f31-0a89-4409-94d3-88c164753c04@googlegroups.com>
In reply to#24437
On Monday, June 25, 2012 7:19:54 PM UTC+1, David Thomas wrote:
> Hello,
> This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
>  How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.
> 
> Thanks

Thank you for the fast response.  How can I tell if Python is in the same path as Terminal?  Is this located in the /usr folder?

Thanks again

[toc] | [prev] | [next] | [standalone]


#24479

FromHans Mulder <hansmu@xs4all.nl>
Date2012-06-26 21:16 +0200
Message-ID<4fea0a7b$0$6942$e4fe514c@news2.news.xs4all.nl>
In reply to#24477
On 26/06/12 20:11:51, David Thomas wrote:
> On Monday, June 25, 2012 7:19:54 PM UTC+1, David Thomas wrote:
>> Hello,
>> This is my first post so go easy on me.  I am just beginning to program using Python on Mac.  When I try to execute a file using Python Launcher my code seems to cause an error in terminal, when I execute the exact same piece of code and run it in windows it seems to execute as exactly intended.
>>  How can I make my python script to open up correctly using Python Launcher?  I am running 10.7 on my Mac.  I would upload a photo with the error I get but I can't seem to find the upload feature in this group.
>>
>> Thanks
> 
> Thank you for the fast response.  How can I tell if Python is in the same path as Terminal?

It isn't.  Terminal is an application and is located in
/Applications/Utilities .  Python is an executable, and is
typically located in a "bin" directory.  To find out where
it is, type

    type python

at the shell prompt (that's the first prompt you get if you
open a Terminal window).

Possible answers include:

/usr/bin/python
    This is the Python shipped by Apple

/Library/Frameworks/Python.framework/Versions/2.7/bin/python
    This is a Python from python.org

/opt/local/bin/python
    This is a Python from macports

> Is this located in the /usr folder?

If you mean /usr/bin, that's the Python that came with your Mac.
If you haven't installed any other Pythons, then yes, you must
be using that one.


Hope this helps,

-- HansM

[toc] | [prev] | [next] | [standalone]


#24483

FromDave Angel <d@davea.name>
Date2012-06-26 16:41 -0400
Message-ID<mailman.1529.1340743349.4697.python-list@python.org>
In reply to#24479
On 06/26/2012 03:16 PM, Hans Mulder wrote:
> <SNIP>
>
>  Python is an executable, and is
> typically located in a "bin" directory.  To find out where
> it is, type
>
>     type python
>
> at the shell prompt (that's the first prompt you get if you
> open a Terminal window).
>
>

That's a typo.  You presumably meant:

    which python

-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#24487

FromHans Mulder <hansmu@xs4all.nl>
Date2012-06-26 23:48 +0200
Message-ID<4fea2e26$0$6883$e4fe514c@news2.news.xs4all.nl>
In reply to#24483
On 26/06/12 22:41:59, Dave Angel wrote:
> On 06/26/2012 03:16 PM, Hans Mulder wrote:
>> <SNIP>
>>
>>  Python is an executable, and is
>> typically located in a "bin" directory.  To find out where
>> it is, type
>>
>>     type python
>>
>> at the shell prompt (that's the first prompt you get if you
>> open a Terminal window).
>>
>>
> 
> That's a typo.  You presumably meant:
> 
>     which python
> 

No, I meant:

$ type python
python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python

'type' is a bash builtin that tells you how bash would interpret
a command.  'which' is a separate program, which tells you how
csh would interpret a command.  For a 'bash' user, 'type' is more
accurate than 'which'.  For example, 'type' recognizes 'bash'
builtins.

-- HansM

[toc] | [prev] | [next] | [standalone]


#24493

FromDave Angel <d@davea.name>
Date2012-06-26 22:38 -0400
Message-ID<mailman.1536.1340764768.4697.python-list@python.org>
In reply to#24487
On 06/26/2012 05:48 PM, Hans Mulder wrote:
> On 26/06/12 22:41:59, Dave Angel wrote:
> <SNIP>

> No, I meant: $ type python python is
> /Library/Frameworks/Python.framework/Versions/2.7/bin/python 'type' is
> a bash builtin that tells you how bash would interpret a command.
> 'which' is a separate program, which tells you how csh would interpret
> a command. For a 'bash' user, 'type' is more accurate than 'which'.
> For example, 'type' recognizes 'bash' builtins. -- HansM 

Thanks for the information. "which" has worked on every unix-like system
I've used for 25 years.  I never knew that bash had its own extension.


-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#24522

FromDavid Thomas <dthomas86@me.com>
Date2012-06-27 10:05 -0700
Message-ID<2401bda7-46a0-4dcb-93e5-4bd739e729d2@googlegroups.com>
In reply to#24487
On Tuesday, June 26, 2012 10:48:22 PM UTC+1, Hans Mulder wrote:
> On 26/06/12 22:41:59, Dave Angel wrote:
> > On 06/26/2012 03:16 PM, Hans Mulder wrote:
> >> <SNIP>
> >>
> >>  Python is an executable, and is
> >> typically located in a "bin" directory.  To find out where
> >> it is, type
> >>
> >>     type python
> >>
> >> at the shell prompt (that's the first prompt you get if you
> >> open a Terminal window).
> >>
> >>
> > 
> > That's a typo.  You presumably meant:
> > 
> >     which python
> > 
> 
> No, I meant:
> 
> $ type python
> python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python
> 
> 'type' is a bash builtin that tells you how bash would interpret
> a command.  'which' is a separate program, which tells you how
> csh would interpret a command.  For a 'bash' user, 'type' is more
> accurate than 'which'.  For example, 'type' recognizes 'bash'
> builtins.
> 
> -- HansM

I have the following:

Is this why I keep getting an error using launcher?  Also to open the script in terminal do I need to put the following at the beginning of my script:  #!/bin/python

On python.org it states to To run your script from the Terminal window you must make sure that /usr/local/bin is in your shell search path.

How can I make sure that the Python I have installed on my Mac is in my shell search path.

http://www.freeimagehosting.net/saskk

Thanks again and I am sorry for all the questions, I am just getting started on Python

[toc] | [prev] | [next] | [standalone]


#24530

FromHans Mulder <hansmu@xs4all.nl>
Date2012-06-27 20:29 +0200
Message-ID<4feb5112$0$6863$e4fe514c@news2.news.xs4all.nl>
In reply to#24522
On 27/06/12 19:05:44, David Thomas wrote:
> Is this why I keep getting an error using launcher?

No.

Yesterday your problem was that you tried this:

    input("\n\nPress the enter key to exit")

That works fine in Pyhton3, but you are using python2
and in python2, the you must do this instead:

    raw_input("\n\nPress the enter key to exit")

If you still get that error, you can either use "raw_input()"
or switch to Python3, where "input" would be correct.

If you're learning Python from a tutorial, you should
carefully read the first section of the tutorial, where
they mention whether the explains pyhton2 or python3,
and use a matching Python (or a matching tutorial).

If the tutorial doesn't say for which version it is,
then it's for pyhton2 (and several years old).

> Also to open the script in terminal do I need to put
> the following at the beginning of my script:
>
> #!/bin/python

No, that doesn't help.

There are at least three pythons on your system, but
there isn't one in /bin.  There are basically two ways
to run a python script in terminal:

Method 1: type the word "python", followed by a space and
the full path to your script, enclosed in quotes, e.g.

python '/Users/dthomaw86/Documents/Python Documents/game_over_enter_key.py'

The quotes are necessary, because you have a space
character in the path.

Method 2:
Step 1: put valid a '#!' line at the top of the script,
for example:

#!/ust/local/bin/python

Step 2: in Terminal, go to the folder where the script is:

    cd '/Users/dthomaw86/Documents/Python Documents'

Step 3: make the script "executable"

    chmod +x game_over_enter_key.py

Step 4: you can now run the script with:

    ./game_over_enter_key.py

If you want to run the script again, you only need to repeat
step 4.  Or use the "up arrow" key in Terminal.

I think you should pick one method and stick with it, until
you get the hang of Terminal.

> On python.org it states to To run your script from the Terminal
> window you must make sure that /usr/local/bin is in your shell
> search path.

The installer for Mac from python.org has installed python2.7
in /Libary/Frameworks/Python.frameworks/Versions/2.7/bin and
added that directory to you shell search path.

> How can I make sure that the Python I have installed on my Mac
> is in my shell search path.
> 
> http://www.freeimagehosting.net/saskk

If you look at the screen shot, you'll see that the shell
has found python in
/Libary/Frameworks/Python.frameworks/Versions/2.7/bin

Incidentally, you don't have to upload screenshots from
Termimal.  You can you just select text in Terminal and
use cmd-C to copy it to the clipboard, and then cmd-V to
paste it to this forum.  This is a text-only forum, but
text from Terminal _is_ text, so that's allowed.

For example:

HansM 4$ cat game_over_enter_key.py
raw_input("\n\nPress the enter key to exit")
HansM 5$ python game_over_enter_key.py


Press the enter key to exit
HansM 6$

> Thanks again and I am sorry for all the questions,
> I am just getting started on Python

That's all right: most people run into this sort of issues
when they try their first script.  There are usually several
ways to do things, and that leads to you getting conflicting
advice.


Hope this helps,

-- HansM

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web