473,505 Members | 15,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python at command prompt

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
13 3982
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
[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
* 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
>[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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2476
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just...
12
2983
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
5
1838
by: waltbrad | last post by:
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 ...
6
5730
by: globalrev | last post by:
type "python setup.py install" that is used in most "addons" for python. well using windows vista, where the h*** am i supposed to type this? if it is not doable in windows, what do i have...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.