python at command prompt

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c3950ig@hotmail.com

    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,

  • Tim Chase

    #2
    Re: python at command prompt

    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.co m/Scripts/PythonForWindow s.html



    Comment

    • c3950ig@hotmail.com

      #3
      Re: python at command prompt

      [snip]
      Sounds like your path isn't set correctly. See the first section
      here[1] on "Finding python.exe"
      >
      -tkc
      >
      [1]http://www.imladris.co m/Scripts/PythonForWindow s.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.

      Comment

      • Mark Elston

        #4
        Re: python at command prompt

        * c3950ig@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.co m/Scripts/PythonForWindow s.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

        Comment

        • Tim Chase

          #5
          Re: python at command prompt

          >[1]http://www.imladris.co m/Scripts/PythonForWindow s.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\python 2.4\bin

          or whatever your path is.

          -tkc





          Comment

          • kyosohma@gmail.com

            #6
            Re: python at command prompt

            On Nov 1, 1:23 pm, Tim Chase <python.l...@ti m.thechases.com wrote:
            [1]http://www.imladris.co m/Scripts/PythonForWindow s.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\python 2.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

            Comment

            • Matimus

              #7
              Re: python at command prompt

              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.co m/Scripts/PythonForWindow s.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\Sc ripts).

              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\Scr ipts.
              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

              Comment

              • Ton van Vliet

                #8
                Re: python at command prompt

                On Thu, 01 Nov 2007 09:17:00 -0700, c3950ig@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

                Comment

                • Tim Roberts

                  #9
                  Re: python at command prompt

                  Ton van Vliet <sheep.in.herd@ green.meadowwro te:
                  >
                  >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.
                  --
                  Tim Roberts, timr@probo.com
                  Providenza & Boekelheide, Inc.

                  Comment

                  • [david]

                    #10
                    Re: python at command prompt

                    Tim Roberts wrote:
                    Ton van Vliet <sheep.in.herd@ green.meadowwro te:
                    >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,

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

                    and
                    "Executable s ... do not need to be registered"


                    [david]

                    Comment

                    • Ton van Vliet

                      #11
                      Re: python at command prompt

                      On Sat, 03 Nov 2007 22:51:05 GMT, Tim Roberts <timr@probo.com wrote:
                      >Ton van Vliet <sheep.in.herd@ green.meadowwro te:
                      >>
                      >>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;.BA T;.CMD;.VBS;.VB E;.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

                      Comment

                      • Ton van Vliet

                        #12
                        Re: python at command prompt

                        On Mon, 05 Nov 2007 11:03:36 +1100, "[david]" <david@nospam.s pam>
                        wrote:
                        >Tim Roberts wrote:
                        >Ton van Vliet <sheep.in.herd@ green.meadowwro te:
                        >>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;.BA T;.CMD;.VBS;.VB E;.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,
                        >
                        >"Executable s (.exe) are always available,"
                        >... provided that the PATHEXT environment variable
                        >has not been set incorrectly...
                        Right
                        >and
                        >"Executable s ... 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\M icrosoft\Window s\CurrentVersio n\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.e xe'

                        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

                        Comment

                        • Tim Roberts

                          #13
                          Re: python at command prompt

                          Ton van Vliet <sheep.in.herd@ green.meadowwro te:
                          >
                          >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, timr@probo.com
                          Providenza & Boekelheide, Inc.

                          Comment

                          • Ton van Vliet

                            #14
                            Re: python at command prompt

                            On Tue, 06 Nov 2007 04:20:17 GMT, Tim Roberts <timr@probo.com wrote:
                            >>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

                            Comment

                            Working...