#! Question

I

Ian Pellew

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
 
O

omission9

Ian said:
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.
 
J

Josiah Carlson

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
 
S

Scott David Daniels

Ian said:
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).
 
J

Josiah Carlson

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
 
J

Josiah Carlson

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
 
J

Jeff Epler

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top