Python 3.3 and .pyo files
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Sep 21 08:55:17 EDT 2012
On Fri, 21 Sep 2012 11:10:07 +0200, Marco wrote:
> I was trying to import a pyo module in Python 3.3, but Python does not
> find it:
>
> $ echo "print(__file__)" > foo.py
> $ python3.3 -O -m foo
> /home/marco/temp/foo.py
> $ ls
> foo.py __pycache__
> $ rm foo.py
> $ mv __pycache__/foo.cpython-33.pyo foo.pyo
I cannot duplicate the creation of the foo.cpython-33.pyo file using just
the -m option. I believe that you created the foo*.pyo file some other
way. Nevertheless, moving along:
> $ rm __pycache__ -r
> $ ls
> foo.pyo
> # The following works in Python3.2, but not in 3.3
> $ python3.3 -O -m foo
> /usr/local/bin/python3.3: No module named foo
I can confirm that (1) it works using Python 3.2; (2) it doesn't work
using Python 3.3; and (3) it does work in Python 3.3 if you don't use the
-O option.
I believe that is a bug.
(Tested using Python 3.2.2 and Python 3.3.0a1)
--
Steven
More information about the Python-list
mailing list