#! Question

Discussion in 'Python' started by Ian Pellew, Feb 20, 2004.

  1. Ian Pellew

    Ian Pellew Guest

    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:\Documents and Settings\ipellew\My Documents\gt.py"
    c:\Progra~1\Python2.3.3\python.exe: can't open file './C:\Documents
    and Settings\ipellew\My Documents\gt.py'

    my python script is in:-
    "C:\Documents and Settings\ipellew\My Documents"

    Regards
    Ian
    Ian Pellew, Feb 20, 2004
    #1
    1. Advertising

  2. Ian Pellew

    omission9 Guest

    Ian Pellew wrote:
    > 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:\Documents and Settings\ipellew\My Documents\gt.py"
    > c:\Progra~1\Python2.3.3\python.exe: can't open file './C:\Documents
    > and Settings\ipellew\My Documents\gt.py'
    >
    > my python script is in:-
    > "C:\Documents and Settings\ipellew\My Documents"
    >
    > Regards
    > Ian

    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.
    omission9, Feb 20, 2004
    #2
    1. Advertising

  3. > 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.


    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
    Josiah Carlson, Feb 20, 2004
    #3
  4. Ian Pellew wrote:

    > 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


    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 David Daniels, Feb 20, 2004
    #4
  5. > 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).
    >


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

    - Josiah
    Josiah Carlson, Feb 21, 2004
    #5
  6. Ian Pellew

    Joe Mason Guest

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

    Joe
    Joe Mason, Feb 21, 2004
    #6
  7. > 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
    Josiah Carlson, Feb 21, 2004
    #7
  8. Ian Pellew

    Jeff Epler Guest

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


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

    jeff
    Jeff Epler, Feb 21, 2004
    #8
  9. "Joe Mason" <> wrote in message
    news:...
    > Is anyone else reading the title of this thread as a curse?
    >
    > Joe


    didn't until that question...
    juergen perlinger, Feb 23, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    589
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    644
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    939
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    413
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    836
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page