By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,814 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,814 IT Pros & Developers. It's quick & easy.

#! Question

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

Jul 18 '05 #2

P: n/a
> 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
Jul 18 '05 #3

P: n/a
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
Sc***********@Acm.Org
Jul 18 '05 #4

P: n/a
> 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
Jul 18 '05 #5

P: n/a
Is anyone else reading the title of this thread as a curse?

Joe
Jul 18 '05 #6

P: n/a
> 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
Jul 18 '05 #7

P: n/a
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

Jul 18 '05 #8

P: n/a

"Joe Mason" <jo*@notcharles.ca> wrote in message
news:sl****************@gate.notcharles.ca...
Is anyone else reading the title of this thread as a curse?

Joe


didn't until that question...
Jul 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.