By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

python at command prompt

P: n/a
Hi,
I am python newbie and the command prompt is having an issue with
python. I installed python 2.4.4 onto my windows machine, opened a
command prompt window, and typed python to start the interactive mode.
Got the following error.

D:\>python
'python' is not recognized as an internal or external command,
operable program or batch file.

The following programs work fine
IDLE (Python GUI)
Python (command line)
PythonWin

For some strange reason, python is not recognized at the command
prompt.
Does anyone have any ideas as to why this is happening?
thanks,

Nov 1 '07 #1
Share this Question
Share on Google+
13 Replies


P: n/a
D:\>python
'python' is not recognized as an internal or external command,
operable program or batch file.
[snip]
For some strange reason, python is not recognized at the command
prompt.
Sounds like your path isn't set correctly. See the first section
here[1] on "Finding python.exe"

-tkc

[1]http://www.imladris.com/Scripts/PythonForWindows.html

Nov 1 '07 #2

P: n/a
[snip]
Sounds like your path isn't set correctly. See the first section
here[1] on "Finding python.exe"

-tkc

[1]http://www.imladris.com/Scripts/PythonForWindows.html
Thanks Tim,
I set the pythonpath to where the python interpreter is located C:
\Python24
However I still get the same error message. Is there something else
that must be configured?
thanks.

Nov 1 '07 #3

P: n/a
* c3*****@hotmail.com wrote (on 11/1/2007 9:58 AM):
[snip]
>Sounds like your path isn't set correctly. See the first section
here[1] on "Finding python.exe"

-tkc

[1]http://www.imladris.com/Scripts/PythonForWindows.html

Thanks Tim,
I set the pythonpath to where the python interpreter is located C:
\Python24
However I still get the same error message. Is there something else
that must be configured?
thanks.
It's not the PYTHONPATH environment variable that you need to set.

You need to set the PATH environment variable to include C:\Python24.
That is where the Python executable is locate.

Mark
Nov 1 '07 #4

P: n/a
>[1]http://www.imladris.com/Scripts/PythonForWindows.html
>
I set the pythonpath to where the python interpreter is located C:
\Python24
However I still get the same error message. Is there something else
that must be configured?
Make sure you're setting your PATH, not your PYTHONPATH variable.

From your command-prompt, issue

c:\test\path

to see what your current path is. You _should_ see your
python2.x\bin folder in there. If not, are you re-using the same
command-prompt window? I vaguely remember that it requires you
to close the cmd window and open a new one to pick up the new
environment-variable changes.

Alternatively, if you don't want to lose history in that
particular window, you can update your path for that particular
window using

c:\test\set path=%PATH%;c:\progra~1\python2.4\bin

or whatever your path is.

-tkc

Nov 1 '07 #5

P: n/a
On Nov 1, 1:23 pm, Tim Chase <python.l...@tim.thechases.comwrote:
[1]http://www.imladris.com/Scripts/PythonForWindows.html
I set the pythonpath to where the python interpreter is located C:
\Python24
However I still get the same error message. Is there something else
that must be configured?

Make sure you're setting your PATH, not your PYTHONPATH variable.

From your command-prompt, issue

c:\test\path

to see what your current path is. You _should_ see your
python2.x\bin folder in there. If not, are you re-using the same
command-prompt window? I vaguely remember that it requires you
to close the cmd window and open a new one to pick up the new
environment-variable changes.

Alternatively, if you don't want to lose history in that
particular window, you can update your path for that particular
window using

c:\test\set path=%PATH%;c:\progra~1\python2.4\bin

or whatever your path is.

-tkc
And if you don't want to do it via the command line, you can right-
click My Computer, choose Properties, click the Advanced Tab and then
hit the Environmental Variables (or just press the Windows Key and
Pause/Break). Anyway, you'll see 2 boxes. Choose the lower one labeled
"System Variables", double-click the Variable labeled "path" and then
just add the path to your Python folder (make sure to separate it from
the one before it with a semi-colon.

For me, it would be something like C:\Python24

Mike

Nov 1 '07 #6

P: n/a
On Nov 1, 9:58 am, c395...@hotmail.com wrote:
[snip]
Sounds like your path isn't set correctly. See the first section
here[1] on "Finding python.exe"
-tkc
[1]http://www.imladris.com/Scripts/PythonForWindows.html

Thanks Tim,
I set the pythonpath to where the python interpreter is located C:
\Python24
However I still get the same error message. Is there something else
that must be configured?
thanks.
You don't want to use PYTHONPATH for pointing to the python
executable. PYTHONPATH is for telling python where to look for
modules. What you need to do is set PATH to point to where the python
exectuable lives (probably C:\Python24) and you might want to add the
scripts directory as well (c:\Python24\Scripts).

To do that, right click on 'My Computer' select 'properties'. In the
dialog that appears select the 'Advanced' tab. Click the 'Environment
Variables' button near the bottom of the dialog. In the System
variables section of the new window look for a variable named 'Path',
and edit its contents to include C:\Python24 and C:\Python24\Scripts.
Each entry should be separated by a semi-colon. There is also a way to
do this by editing the registry which I'm sure you could find by doing
a google search.

I'm a little surprised that python doesn't do this by default, or at
least give it as an option during installation.

Matt

Nov 1 '07 #7

P: n/a
On Thu, 01 Nov 2007 09:17:00 -0700, c3*****@hotmail.com wrote:
>Hi,
I am python newbie and the command prompt is having an issue with
python. I installed python 2.4.4 onto my windows machine, opened a
command prompt window, and typed python to start the interactive mode.
Got the following error.

D:\>python
'python' is not recognized as an internal or external command,
operable program or batch file.

The following programs work fine
IDLE (Python GUI)
Python (command line)
PythonWin

For some strange reason, python is not recognized at the command
prompt.
Does anyone have any ideas as to why this is happening?
thanks,
There's could also be an issue with entering 'python' at the command
line, and not 'python.exe'. Once the PATH is setup correctly, try to
enter 'python.exe', and check whether that works.

IMHO, to get any 'program-name' (without the .exe extension) to work,
one needs to:
1. register the executable with windows (doesn't work for python) or
2. make sure the the PATHEXT environment variable is set correctly,
and includes the .EXE extension (on my w2k system it looks like:
..COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH)

--
Ton

Nov 2 '07 #8

P: n/a
Ton van Vliet <sh***********@green.meadowwrote:
>
There's could also be an issue with entering 'python' at the command
line, and not 'python.exe'. Once the PATH is setup correctly, try to
enter 'python.exe', and check whether that works.

IMHO, to get any 'program-name' (without the .exe extension) to work,
one needs to:
1. register the executable with windows (doesn't work for python) or
2. make sure the the PATHEXT environment variable is set correctly,
and includes the .EXE extension (on my w2k system it looks like:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WS H)
You're confusing two things here. Executables (.exe) are always available,
and do not need to be registered to be run without the extension.

It is possible to have Windows execute "abc.py" when you type "abc", and
that DOES require registering the .py extension and adding .py to the
PATHEXT environment variable.

A very useful thing to do, by the way. I have many command line tools for
which I have forgotten whether they are batch files, small executables, or
Python scripts. And that's how it should be.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 3 '07 #9

P: n/a
Tim Roberts wrote:
Ton van Vliet <sh***********@green.meadowwrote:
>There's could also be an issue with entering 'python' at the command
line, and not 'python.exe'. Once the PATH is setup correctly, try to
enter 'python.exe', and check whether that works.

IMHO, to get any 'program-name' (without the .exe extension) to work,
one needs to:
1. register the executable with windows (doesn't work for python) or
2. make sure the the PATHEXT environment variable is set correctly,
and includes the .EXE extension (on my w2k system it looks like:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WS H)

You're confusing two things here. Executables (.exe) are always available,
and do not need to be registered to be run without the extension.

It is possible to have Windows execute "abc.py" when you type "abc", and
that DOES require registering the .py extension and adding .py to the
PATHEXT environment variable.

A very useful thing to do, by the way. I have many command line tools for
which I have forgotten whether they are batch files, small executables, or
Python scripts. And that's how it should be.
That is,

"Executables (.exe) are always available,"
.... provided that the PATHEXT environment variable
has not been set incorrectly...

and
"Executables ... do not need to be registered"
[david]
Nov 5 '07 #10

P: n/a
On Sat, 03 Nov 2007 22:51:05 GMT, Tim Roberts <ti**@probo.comwrote:
>Ton van Vliet <sh***********@green.meadowwrote:
>>
There's could also be an issue with entering 'python' at the command
line, and not 'python.exe'. Once the PATH is setup correctly, try to
enter 'python.exe', and check whether that works.

IMHO, to get any 'program-name' (without the .exe extension) to work,
one needs to:
1. register the executable with windows (doesn't work for python) or
2. make sure the the PATHEXT environment variable is set correctly,
and includes the .EXE extension (on my w2k system it looks like:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH )
please note that I state 1 *or* 2
>You're confusing two things here. Executables (.exe) are always available,
and do not need to be registered to be run without the extension.
but *only* if the PATHEXT environment variable is setup correctly
>It is possible to have Windows execute "abc.py" when you type "abc", and
that DOES require registering the .py extension and adding .py to the
PATHEXT environment variable.
There are executables (.exe) that have a 'registering' option builtin,
and need to be registered to have their capabilities made available
using the /regserver switch (possibly related to OLE/COM services, but
I'm not an expert here ;-)

see: http://consumer.installshield.com/kb.asp?id=Q108199 (last para)
>A very useful thing to do, by the way. I have many command line tools for
which I have forgotten whether they are batch files, small executables, or
Python scripts. And that's how it should be.
--
Ton
Nov 5 '07 #11

P: n/a
On Mon, 05 Nov 2007 11:03:36 +1100, "[david]" <da***@nospam.spam>
wrote:
>Tim Roberts wrote:
>Ton van Vliet <sh***********@green.meadowwrote:
>>There's could also be an issue with entering 'python' at the command
line, and not 'python.exe'. Once the PATH is setup correctly, try to
enter 'python.exe', and check whether that works.

IMHO, to get any 'program-name' (without the .exe extension) to work,
one needs to:
1. register the executable with windows (doesn't work for python) or
2. make sure the the PATHEXT environment variable is set correctly,
and includes the .EXE extension (on my w2k system it looks like:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH )

You're confusing two things here. Executables (.exe) are always available,
and do not need to be registered to be run without the extension.

It is possible to have Windows execute "abc.py" when you type "abc", and
that DOES require registering the .py extension and adding .py to the
PATHEXT environment variable.

A very useful thing to do, by the way. I have many command line tools for
which I have forgotten whether they are batch files, small executables, or
Python scripts. And that's how it should be.

That is,

"Executables (.exe) are always available,"
... provided that the PATHEXT environment variable
has not been set incorrectly...
Right
>and
"Executables ... do not need to be registered"
Right also, however they may be 'registered' to get a 'similar' kind
of response:

If you have a look at the following registry key:
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
you may find several 'registered' applications that can be launched
without appending the .exe extension from the 'start|run' menu

If you want to experiment for yourself: (needless to say: be carefull)

1. Select a small stand-alone .exe application of your choice
2. *copy* the .exe into some directory that is not on your PATH (e.g.
d:\temp)
3. Rename the application (e.g. to 'eppo.exe')
4. Open regedit and add an 'eppo.exe' to the above mentioned 'App
Paths' key
5. Modify its (Default) value to 'd:\temp\eppo.exe'

From now on you can just enter 'eppo' at 'Start|Run' entry field, to
launch the application

To make entering 'eppo' working at the command prompt, the directory
in which the eppo.exe is located must be in the (search) PATH, even if
the PATHEXT is *not* setup correctly.

If the applications directory is not on your PATH, you may still start
it with 'start eppo'

I definitely am not an expert in this area, so may someone else may
come with a better explanation of this .exe registering stuff, I'm
sure there's more involved (like setting of the 'open with' keys,
registering COM servers, etc) but I just wanted to bring up that
'registering' executables is not *that* uncommon.

HTH ;-)
--
Ton
Nov 5 '07 #12

P: n/a
Ton van Vliet <sh***********@green.meadowwrote:
>
There are executables (.exe) that have a 'registering' option builtin,
and need to be registered to have their capabilities made available
using the /regserver switch (possibly related to OLE/COM services, but
I'm not an expert here ;-)
Yes, that's strictly for COM. And the "App Paths" registry key you
mentioned is only for Explorer things, like the Start menu's "Run" box. It
doesn't apply to the command line. Try typing "wordpad" in a cmd shell,
then try it in Start -Run.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 6 '07 #13

P: n/a
On Tue, 06 Nov 2007 04:20:17 GMT, Tim Roberts <ti**@probo.comwrote:
>>There are executables (.exe) that have a 'registering' option builtin,
and need to be registered to have their capabilities made available
using the /regserver switch (possibly related to OLE/COM services, but
I'm not an expert here ;-)

Yes, that's strictly for COM.
Thanks for the confirmation.
>And the "App Paths" registry key you mentioned is only for Explorer
things, like the Start menu's "Run" box. It doesn't apply to the
command line. Try typing "wordpad" in a cmd shell, then try it
in Start -Run.
Which, as I learned now, can be 'simulated' by typing 'start wordpad'
at the command line (I wasn't aware of that before)

Let's hope the OP got his problem solved ;-)

--
Ton
Nov 6 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.