#! Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Pellew

    #! Question

    Hi All;

    How do I get line one to call python:-
    This is line one in my python script
    #!C:/Program Files/Python2.3.3/python.exe

    gives:-
    Win32_Prompt> "C:\Documen ts and Settings\ipelle w\My Documents\gt.py "
    c:\Progra~1\Pyt hon2.3.3\python .exe: can't open file './C:\Documents
    and Settings\ipelle w\My Documents\gt.py '

    my python script is in:-
    "C:\Documen ts and Settings\ipelle w\My Documents"

    Regards
    Ian
  • omission9

    #2
    Re: #! Question

    Ian Pellew wrote:[color=blue]
    > Hi All;
    >
    > How do I get line one to call python:-
    > This is line one in my python script
    > #!C:/Program Files/Python2.3.3/python.exe
    >
    > gives:-
    > Win32_Prompt> "C:\Documen ts and Settings\ipelle w\My Documents\gt.py "
    > c:\Progra~1\Pyt hon2.3.3\python .exe: can't open file './C:\Documents
    > and Settings\ipelle w\My Documents\gt.py '
    >
    > my python script is in:-
    > "C:\Documen ts and Settings\ipelle w\My Documents"
    >
    > Regards
    > Ian[/color]
    You should have python.exe in you path. In any event, the space in
    "Program Files" is sure to cause trouble. Put anything with spaces
    inside double quotes.
    #!"C:/Program Files/Python2.3.3/python.exe" will work.

    Comment

    • Josiah Carlson

      #3
      Re: #! Question

      > You should have python.exe in you path. In any event, the space in[color=blue]
      > "Program Files" is sure to cause trouble. Put anything with spaces
      > inside double quotes.
      > #!"C:/Program Files/Python2.3.3/python.exe" will work.[/color]

      Not on windows. On windows, no amount of #! trickery will get you
      anywhere (unless you are using bash, sh, etc. in windows via cygwin).
      For good or evil, windows uses file-extension associations. That is, in
      order to be able to open a file that is not an executable, shortcut, or
      batch file (exe, com, scr, pif, lnk, bat, cmd, etc.), Windows must have
      the proper association for that file type.

      From windows explorer, double-click on the .py file. When it pops up
      with, "What should I open this with?" select the the proper python
      executable, and you are home free.

      - Josiah

      Comment

      • Scott David Daniels

        #4
        Re: #! Question

        Ian Pellew wrote:
        [color=blue]
        > How do I get line one to call python:-
        > This is line one in my python script
        > #!C:/Program Files/Python2.3.3/python.exe[/color]

        As Josiah Carlson pointed out, the mechanism on windows is
        different. You can figure out how to do this in the command
        line environment by typing "HELP ASSOC" and "HELP FTYPE".
        Essentially, there is a two-layer association between file
        extensions and programs. ASSOC sets the association of an
        extension with a file type. FTYPE associates a file type
        with a command.

        So, after typing the following to your command processor:

        ASSOC .py=Python.File
        FTYPE Python.File=C:\ python23\python .exe %1 %*

        You should be able to run python files by simply typing their
        name (assuming a standard python 2.3 install on drive C).

        --
        -Scott David Daniels
        Scott.Daniels@A cm.Org

        Comment

        • Josiah Carlson

          #5
          Re: #! Question

          > So, after typing the following to your command processor:[color=blue]
          >
          > ASSOC .py=Python.File
          > FTYPE Python.File=C:\ python23\python .exe %1 %*
          >
          > You should be able to run python files by simply typing their
          > name (assuming a standard python 2.3 install on drive C).
          >[/color]

          I didn't know about those commands. Talk about useful.

          - Josiah

          Comment

          • Joe Mason

            #6
            Re: #! Question

            Is anyone else reading the title of this thread as a curse?

            Joe

            Comment

            • Josiah Carlson

              #7
              Re: #! Question

              > Is anyone else reading the title of this thread as a curse?

              No, but I am reading it as "pound-bang" or "hash-bang".

              - Josiah

              Comment

              • Jeff Epler

                #8
                Re: #! Question

                On Sat, Feb 21, 2004 at 05:09:23PM +0000, Joe Mason wrote:[color=blue]
                > Is anyone else reading the title of this thread as a curse?[/color]

                some folks call #!... the "shebang line" of a shell script, but maybe
                that falls afoul of content filters...

                jeff

                Comment

                • juergen perlinger

                  #9
                  Re: #! Question


                  "Joe Mason" <joe@notcharles .ca> wrote in message
                  news:slrnc3f2jp .9s6.joe@gate.n otcharles.ca...[color=blue]
                  > Is anyone else reading the title of this thread as a curse?
                  >
                  > Joe[/color]

                  didn't until that question...


                  Comment

                  Working...