python from any command line?

Discussion in 'Python' started by waltbrad, Dec 9, 2007.

  1. waltbrad

    waltbrad Guest

    Hi folks. I'm learning Python from the Mark Lutz Book, Programming
    Python 3rd edition.

    He seems to be able to invoke the Python interpreter from any command
    line prompt.

    C:\temp>python

    C:\PP3rdEd\examples>python

    C:\PP3rdEd\Examples\PP3E\System>cd

    Whereas I am only able to invoke it when the command line is pointing
    to the directory where the executable resides. Currently:

    C:\Python25

    Is there a way to set this so I can also invoke it from any command
    line prompt?

    Thankyou very much.
    waltbrad, Dec 9, 2007
    #1
    1. Advertising

  2. waltbrad wrote:
    > Hi folks. I'm learning Python from the Mark Lutz Book, Programming
    > Python 3rd edition.
    >
    > He seems to be able to invoke the Python interpreter from any command
    > line prompt.
    >
    > C:\temp>python
    >
    > C:\PP3rdEd\examples>python
    >
    > C:\PP3rdEd\Examples\PP3E\System>cd
    >
    > Whereas I am only able to invoke it when the command line is pointing
    > to the directory where the executable resides. Currently:
    >
    > C:\Python25
    >
    > Is there a way to set this so I can also invoke it from any command
    > line prompt?
    >
    > Thankyou very much.


    The Python executable must be found in your system path, that is why you
    are unable to just simply type python at anytime at a command prompt.
    Simple fix:

    click Start > Control Panel > System > Advanced > Environment Variables
    (bottom right)

    Then you will have two list boxes one for user environment variables
    another for system variables. I prefer placing the path in the System
    environment variables section that way it is available for all accounts
    on the system (provided you have more than 1 user on it).

    In the System list locate the Path variables, select edit variable and
    append ;C:\Python25 to it. And thats it reopen a new command prompt the
    type python and it should just fire up.

    Hope this helps.

    Adonis Vargas
    Adonis Vargas, Dec 9, 2007
    #2
    1. Advertising

  3. waltbrad

    waltbrad Guest

    On Dec 9, 8:54 am, Adonis Vargas <>
    wrote:
    > waltbrad wrote:
    > > Hi folks. I'm learning Python from the Mark Lutz Book, Programming
    > > Python 3rd edition.

    >
    > > He seems to be able to invoke the Python interpreter from any command
    > > line prompt.

    >
    > > C:\temp>python

    >
    > > C:\PP3rdEd\examples>python

    >
    > > C:\PP3rdEd\Examples\PP3E\System>cd

    >
    > > Whereas I am only able to invoke it when the command line is pointing
    > > to the directory where the executable resides. Currently:

    >
    > > C:\Python25

    >
    > > Is there a way to set this so I can also invoke it from any command
    > > line prompt?

    >
    > > Thankyou very much.

    >
    > The Python executable must be found in your system path, that is why you
    > are unable to just simply type python at anytime at a command prompt.
    > Simple fix:
    >
    > click Start > Control Panel > System > Advanced > Environment Variables
    > (bottom right)
    >
    > Then you will have two list boxes one for user environment variables
    > another for system variables. I prefer placing the path in the System
    > environment variables section that way it is available for all accounts
    > on the system (provided you have more than 1 user on it).
    >
    > In the System list locate the Path variables, select edit variable and
    > append ;C:\Python25 to it. And thats it reopen a new command prompt the
    > type python and it should just fire up.
    >
    > Hope this helps.
    >
    > Adonis Vargas


    Got it, Adonis. Thanks much.
    waltbrad, Dec 9, 2007
    #3
  4. waltbrad

    john Guest

    Hi,

    You need to edit your path variable. (I'm assuming you're using
    Windows). Go to:

    Settings > Control Panel > System > Advanced > Environment Variables.

    Now double click on 'Path' and append ";C:\Python25\" (minus the
    quotation marks) to the text displayed in the Variable Value box.

    BW,

    John
    john, Dec 9, 2007
    #4
  5. waltbrad wrote:
    > Is there a way to set this so I can also invoke it from any command
    > line prompt?


    You can follow Adonis' advice but I'm going a different path on my
    computer because I've multiple versions of Python installed on my box.

    I usually put a simple batch file in c:\Windows, e.g. python25.bat

    @C:\Python25\python.exe %*

    I can start Python 2.5 with python25 from every directory.

    Christian
    Christian Heimes, Dec 9, 2007
    #5
  6. waltbrad wrote:
    > Is there a way to set this so I can also invoke it from any command
    > line prompt?


    You can follow Adonis' advice but I'm going a different path on my
    computer because I've multiple versions of Python installed on my box.

    I usually put a simple batch file in c:\Windows, e.g. python25.bat

    @C:\Python25\python.exe %*

    I can start Python 2.5 with python25 from every directory.

    Christian
    Christian Heimes, Dec 9, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,035
    Tohid
    Oct 23, 2003
  2. Bernd Oninger
    Replies:
    1
    Views:
    775
    Martin Honnen
    Jul 7, 2004
  3. Replies:
    4
    Views:
    1,695
    Terry Hancock
    Apr 23, 2005
  4. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    223
    Genich
    Oct 22, 2003
  5. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    189
    Oliver
    Oct 22, 2003
Loading...

Share This Page