Error confusing a newbie

Jeff jam at quark.emich.edu
Sat Dec 11 15:16:22 EST 1999


On Sat, Dec 11, 1999 at 02:04:50PM -0500, Wayne Topa wrote:
> Yes Jeff, that is the only way it _does_ work. as I described in my
> original post. 
> 

ok. I don't mean to rehash old points, but it was necessary to double check
the facts. if you are able to run it without problems by giving the script
directly to the interpreter, then indeed the problem is in the configuration
of the environment, and python itself should not be blamed for the problem.

> As I have been burned before, using tabs, I now uses spaces only, for
> indentation.
> 

ok. consistency is key. 

> Originallly I wrote it using vim and just checked it with Jed, spaces
> and no tabs.  I just ran tabpolice.py on net_time.py and it didn't
> complain so I am 99.999% sure that I have only spaces.
> 

good.

> >| 
> >| what does your PATH variable look like for the root account? is 'python' in
> >| the path? does the situation change if you remove the '/usr/bin/env' and put
> >| the absolute path to the interpreter in it's place (i.e.
> >| '#!/usr/local/bin/python')?
> 
> running ' python net_time.py'  works correctly no matter if the
> header line is #!/usr/bin/python or  #!/usr/bin/env python.
> 

well, when you run the python interpreter, and give it a script on the
command line, it ignores lines with "#" characters (or, more correctly,
everything beyond the '#' character). this is very much expected behavior.
did you change the '/usr/bin/env...' part to a direct path to the
interpreter and get different results, or the same problem?

> It gives the error
> VT3 root-Deb-Slink:/program/Python# ./net_time.py
> import: Unable to connect to X server () [No such file or directory].
> from: can't read /var/spool/mail/DateTime.
> ./net_time.py: line 7: syntax error near unexpected token `open(''
> ./net_time.py: line 7: `input = open('/var/log/totalppp', 'r')'
> 

this is definately the shell (probably bash) interpreting the python code
for itself. another response mentioned that 'import' is a common tool for
conversion of graphics formats (or maybe taking screen shots, I can't
remember).. at any rate, the errors are *not* from the python interpreter,
but rather the shell complaining about the input you are feeding it.

> with either version and it is executable
> VT3 root-Deb-Slink:/program/Python# ls -l net_time.py
> -rwxr-xr-x   1 root     root          839 Dec 11 13:39 net_time.py
> 

if the script wasn't marked executable, you wouldn't have gotten as far as
you did, so I know that isn't the issue.

> 
> The complete script is included in my first post of this problem.
>

I'll check the archives for the original script, but again I don't think
there's anything wrong with your python code, since you mention that it
works ok when you run it as 'python net_time.py'.

> Well it didn't help but then again it didn't hurt either.  You did
> make me wonder so I went and re-checked all of your points.  This one
> os a stinker!
> 

definately.. I would comb the config of the shell for problems. try changing
the '#!' line as I mentioned and see if that solves the problem. perhaps
the 'env' program is the actual culprite.

> Thanks Jeff
> 

regards,
J
-- 
|| visit gfd <http://quark.emich.edu/>
|| psa member -- <http://www.python.org/psa/> 
|| New Image Systems & Services, Inc. <http://www.newimage.com/>




More information about the Python-list mailing list