Running python from cygwin with .py-extension --- import: not found
Steve Holden
sholden at holdenweb.com
Thu Sep 7 14:10:31 EDT 2000
More information about the Python-list mailing list
Thu Sep 7 14:10:31 EDT 2000
- Previous message (by thread): xml and Python 2.0b
- Next message (by thread): Running python from cygwin with .py-extension --- import: not found
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Olav wrote: > > Calvelo Daniel wrote: > > > > > It seems that your script is not interpreted by Python. Those are not > > Python errors. > > No, the script is interpreted. The problem is importing the libraries: > Yes, but interpreted by what? > /home/olav> cat hello.py > print "Hello world" > /home/olav> hello.py > Can't find file Hello world I'm guessing that your shell is finding a "print" command on your PATH, but that the "print" command can't find what it thinks to be a file. > /home/olav> cat hello2.py > import os > print "Hello world" > /home/olav> hello2.py > import: not found This strongly corroborates the suspicion that your shell* is doing the interpretation and not the Python interpreter. No Python interpreter would complain about import, and even if it did it would raise a Name exception rather than using the "not found" message. > Can't find file Hello world This is the shell* compaining about the SECOND line of the script. > /home/olav> python hello2.py > Hello world > /home/olav> > Aha! So when the Python interpreter sees your script it does indeed interpret it correctly. > (....That it is trying to look for the file-name instead of printing is also > interesting.....) > > > > > > I tried to use a script with a '#!/usr/bin/env python' first line > > and it works exactly as in UNIX, ie call it directly after a 'chmod +x'. > > I am uing PATHEXT=.COM;.EXE;.BAT;.CMD;.ph > (in the NT environment this variable is in fact not visible in cygwin) > > .....Though perhaps I should look into the "#"-way of doing it? > > > Merci! > Olav > You might want to look into http://www.toolwood.dk/freeware/PythonLauncher or take advice about how otherwise to make Python scripts executable in the Windows NT environment. The "#!" hack is solely for U**x, sorry. regards Steve * For "shell" above, read "NT command interpreter". -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/
- Previous message (by thread): xml and Python 2.0b
- Next message (by thread): Running python from cygwin with .py-extension --- import: not found
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list