The python not starting under cmd.exe

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

    The python not starting under cmd.exe

    Hi!

    My problem is that:
    The "test.py" is working in every machine that I use except in my home
    machine.
    Formerly it worked but now not. I don't know what happened, I searching
    for some solution.

    The errormessage is this (after I tried to start test.py under cmd.exe):

    Microsoft Windows XP [verziószám: 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    c:\>test.py
    A rendszer nem tudja végrehajtani a megadott programot.

    c:\>


    Sorry for non english, I try to translate it:
    "The system cannot execute the program/application."

    Interesting thing that the starting from Explorer, FreeCommander, or
    other tool (Double clicking, Hit enter on it) is working good, so the
    "py" linked to the python.
    I tried to set path, and pathext too but it have no effect.

    This command is working:
    "python test.py".

    I don't know, why not working the "test.py" command, because in other
    machines it is working good... :-(((((

    Thanks for any advance in this problem!

    dd

  • Ulrich Eckhardt

    #2
    Re: The python not starting under cmd.exe

    durumdara@gmail .com wrote:
    The "test.py" is working in every machine that I use except in my home
    machine.
    [...]
    c:\>test.py
    A rendszer nem tudja végrehajtani a megadott programot.
    >
    c:\>
    >
    >
    Sorry for non english, I try to translate it:
    "The system cannot execute the program/application."
    >
    Interesting thing that the starting from Explorer, FreeCommander, or
    other tool (Double clicking, Hit enter on it) is working good, so the
    "py" linked to the python.
    Maybe, maybe not. This 'linked to' is a notion of the shell (i.e. the
    Explorer) so it doesn't apply to the CLI necessarily. Anyhow: I guess you
    also can't run the interactive Python interpreter from the commandline
    (just type 'python' to test that). If that is the case, you simply need to
    add the path to the interpreter to the PATH environment variable:

    set PATH=C:\Python4 2;%PATH%

    You can also set this somewhere in your user profile, otherwise it only
    affects the current commandline and processes started from it.
    I tried to set path, and pathext too but it have no effect.
    >
    This command is working:
    "python test.py".
    Hmm, strange. From where did you issue that command? If it was from the
    Python install dir, it will find the local python.exe even without the path
    and might not do the same when it tries to find the handler from a call to
    test.py. And what did you try to set the PATH and PATHEXT to?

    Good luck and please drop a note if you manage to solve the issue!

    Uli

    --
    Sator Laser GmbH
    Geschäftsführ er: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

    Comment

    • John Machin

      #3
      Re: The python not starting under cmd.exe

      On Aug 13, 6:34 pm, "durumd...@gmai l.com" <durumd...@gmai l.comwrote:
      Hi!
      >
      My problem is that:
      The "test.py" is working in every machine that I use except in my home
      machine.
      Formerly it worked but now not. I don't know what happened, I searching
      for some solution.
      >
      The errormessage is this (after I tried to start test.py under cmd.exe):
      >
      Microsoft Windows XP [verziószám: 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.
      >
      c:\>test.py
      A rendszer nem tudja végrehajtani a megadott programot.
      >
      c:\>
      >
      Sorry for non english, I try to translate it:
      "The system cannot execute the program/application."
      >
      Interesting thing that the starting from Explorer, FreeCommander, or
      other tool (Double clicking, Hit enter on it) is working good, so the
      "py" linked to the python.
      I tried to set path, and pathext too but it have no effect.
      >
      This command is working:
      "python test.py".
      >
      I don't know, why not working the "test.py" command, because in other
      machines it is working good... :-(((((
      This may help:
      ====
      C:\junk>help assoc
      Displays or modifies file extension associations

      ASSOC [.ext[=[fileType]]]

      .ext Specifies the file extension to associate the file type
      with
      fileType Specifies the file type to associate with the file
      extension

      Type ASSOC without parameters to display the current file
      associations.
      If ASSOC is invoked with just a file extension, it displays the
      current
      file association for that file extension. Specify nothing for the
      file
      type and the command will delete the association for the file
      extension.

      C:\junk>assoc .py
      .py=Python.File

      C:\junk>help ftype
      Displays or modifies file types used in file extension associations

      FTYPE [fileType[=[openCommandStri ng]]]

      fileType Specifies the file type to examine or change
      openCommandStri ng Specifies the open command to use when launching
      files
      of this type.

      Type FTYPE without parameters to display the current file types that
      have open command strings defined. FTYPE is invoked with just a file
      type, it displays the current open command string for that file type.
      Specify nothing for the open command string and the FTYPE command will
      delete the open command string for the file type. Within an open
      command string %0 or %1 are substituted with the file name being
      launched through the assocation. %* gets all the parameters and %2
      gets the 1st parameter, %3 the second, etc. %~n gets all the
      remaining
      parameters starting with the nth parameter, where n may be between 2
      and 9,
      inclusive. For example:

      ASSOC .pl=PerlScript
      FTYPE PerlScript=perl .exe %1 %*

      would allow you to invoke a Perl script as follows:

      script.pl 1 2 3

      If you want to eliminate the need to type the extensions, then do the
      following:

      set PATHEXT=.pl;%PA THEXT%

      and the script could be invoked as follows:

      script 1 2 3

      C:\junk>ftype python.file
      python.file="C: \Python25\pytho n.exe" "%1" %*

      ====
      HTH,
      John

      Comment

      • durumdara@gmail.com

        #4
        Re: The python not starting under cmd.exe

        Hi!

        nntpman68 írta:
        Did you try
        >
        start test.py
        >
        from the command line?
        >
        Normally this tries to behave as if you clicked on the file from the
        explorer?
        >
        >
        bye
        The associations, filetypes are good:

        H:\Dev\ImgOrder >ASSOC .py
        ..py=Python.Fil e

        H:\Dev\ImgOrder >ftype python.file
        python.file="C: \Python25\pytho n.exe" "%1" %*

        But the start not working. And not only Python Program, but all start
        failed...

        In other machines the start "anything.x ls", or "anything.h tml" or
        "anything.j pg" is working good, it is starts the program that associated
        with this file, and open the file.

        But in this machine is not working. So it is not pythonic, it is windows
        problem.

        Thanks for your help! For everyone who helped me!

        dd

        Comment

        • Fredrik Lundh

          #5
          Re: The python not starting under cmd.exe

          durumdara@gmail .com wrote:
          H:\Dev\ImgOrder >ftype python.file
          python.file="C: \Python25\pytho n.exe" "%1" %*
          >
          But the start not working. And not only Python Program, but all start
          failed...
          >
          In other machines the start "anything.x ls", or "anything.h tml" or
          "anything.j pg" is working good, it is starts the program that associated
          with this file, and open the file.
          >
          But in this machine is not working. So it is not pythonic, it is windows
          problem.
          you might want to check if your antivirus/security software is somehow
          involved with this (that's more likely on corporate machines, though,
          where admins love to set corporate-wide "policies" that mess things up
          for programmers ;-).

          </F>

          Comment

          Working...