python from any command line?

W

waltbrad

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.
 
A

Adonis Vargas

waltbrad said:
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
 
W

waltbrad

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.
 
J

john

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
 
C

Christian Heimes

waltbrad said:
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
 
C

Christian Heimes

waltbrad said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top