.pyo's without .pyc's?

Randall Hopper aa8vb at yahoo.com
Thu Jul 8 07:41:13 EDT 1999


M.-A. Lemburg:
 |Looks like you have setup PYTHONPATH to point to some old
 |extensions.py file (the compiled versions seemed to be ok).

It doesn't appear this is the case (please see below).

 |Try "python -vv" to have a look at the path scanning Python
 |does on startup.

I've attached the two different search outputs below.  As you can see, even
with -O, it's searching .pyc files even when .pyo is specified.  As far as
I've heard, this is incorrect behavior.

 |Running Python with .pyo files only works just fine if you
 |remember to always use the -O flag on the command line.

I hope it can be made to work that way, but it doesn't seem to.

 |For minimalist Python installs, you could also check out the
 |mxCGIPython project:
 |
 |	http://starship.skyport.net/~lemburg/mxCGIPython.html
 |
 |It's Python wrapped into a single file (with the standard
 |lib compiled with -O BTW).

Alas, I need Tkinter compiled in and IIRC this doesn't work well with Tk
yet.

Thanks,

-- 
Randall Hopper
aa8vb at yahoo.com


-------------------------------------------------------------------------------

~/software/python-1.5.2 >  unsetenv PYTHONPATH
~/software/python-1.5.2 >  setenv PATH "/bin::usr/bin"
~/software/python-1.5.2 >  pwd
/home/rhh/software/python-1.5.2
~/software/python-1.5.2 >  ls
bin      demos    include  lib      man      tools
~/software/python-1.5.2 >  bin/python
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 
~/software/python-1.5.2 >  bin/python -O
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 

~/software/python-1.5.2 >  find . -name '*.py' -print | xargs rm
~/software/python-1.5.2 >  bin/python
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 
~/software/python-1.5.2 >  bin/python -O
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 

~/software/python-1.5.2 >  find . -name '*.py' -print | xargs rm
Incorrect usage
Usage: rm [-fir] file ...
~/software/python-1.5.2 >  find . -name '*.pyc' -print | xargs rm
~/software/python-1.5.2 >  bin/python
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import exceptions' failed; use -v for traceback
Warning!  Falling back to string-based exceptions
'import site' failed; use -v for traceback
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 
~/software/python-1.5.2 >  bin/python -O
'import exceptions' failed; use -v for traceback
Warning!  Falling back to string-based exceptions
Python 1.5.2 (#1, Apr 14 1999, 07:55:56) [C] on irix646-n32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 
~/software/python-1.5.2 >  exit

script done on Thu Jul  8 07:25:00 1999

-------------------------------------------------------------------------------

Successful exceptions module search -- unadulterated install tree:

> find . -name 'exceptions*'
./lib/python1.5/exceptions.py
./lib/python1.5/exceptions.pyo
./lib/python1.5/exceptions.pyc

> bin/python -O -vv | & grep except
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptionsmodule.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.py
# /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.pyo matches /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.py
import exceptions # precompiled from /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.pyo

-------------------------------------------------------------------------------

Unsuccessful exceptions module search -- *.py and *.pyc pruned:

> find . -name 'exceptions*'
./lib/python1.5/exceptions.pyo

> bin/python -O -vv | & grep except
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptionsmodule.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.py
# trying /home/rhh/software/python-1.5.2/lib/python1.5/exceptions.pyc
# trying /home/rhh/software/python-1.5.2/lib/python1.5/plat-irix646-n32/exceptions.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/plat-irix646-n32/exceptionsmodule.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/plat-irix646-n32/exceptions.py
# trying /home/rhh/software/python-1.5.2/lib/python1.5/plat-irix646-n32/exceptions.pyc
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-tk/exceptions.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-tk/exceptionsmodule.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-tk/exceptions.py
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-tk/exceptions.pyc
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-dynload/exceptions.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-dynload/exceptionsmodule.so
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-dynload/exceptions.py
# trying /home/rhh/software/python-1.5.2/lib/python1.5/lib-dynload/exceptions.pyc
'import exceptions' failed; traceback:
ImportError: No module named exceptions
Warning!  Falling back to string-based exceptions




More information about the Python-list mailing list