pyc runtime error
Rami Chowdhury
rami.chowdhury at gmail.com
Wed Jun 30 04:31:42 EDT 2010
On 2010-06-30 01:06, Baris CUHADAR wrote:
> Can anyone explain this unexpected behavior?
I'm sorry -- can you let us know what behavior you're expecting?
> all files chmod 755, i've compiled x.py with py_compilefiles,
> also tried within python console with "import x"
>
> system: centos 5.4 32bit
>
> This a PATH related problem i think?
>
Perhaps I'm misunderstanding what you're trying to do but from what I can
see, you are expecting .pyc files to be directly executed by the shell. And
as I understand them, they are *not* meant to be directly executed by the
shell at all -- they're simply a sometimes-useful shortcut for the Python
interpreter.
Python scripts like your x.py, however, *are* meant to be executed by the
shell. Have you tried:
[user at box cgi-bin]$ ./x.py
?
> [root at centos-14 cgi-bin]# ./x.pyc
May I ask, as well, why you're doing all of this as root?
>
>
> [root at centos-14 cgi-bin]# python x.pyc
> Content-Type:text/html
>
>
> python
> 2.4.3 (#1, Sep 3 2009, 15:37:12)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
>
> --------------------------------------------------------------------------------------------
>
> x.py file content:
>
> #!/usr/bin/env python
>
> print "Content-Type:text/html\n\n"
> print "python"
> import sys
> print sys.version
>
> --------------------------------------------------------------------------------------------
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list