Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29714
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Python 3.3 and .pyo files |
| Date | 2012-09-21 22:46 -0400 |
| References | <k3hatd$kto$1@speranza.aioe.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1057.1348281994.27098.python-list@python.org> (permalink) |
On 9/21/2012 5:10 AM, Marco wrote: > I was trying to import a pyo module in Python 3.3, but Python does not > find it: You appear to be trying to *run*, not *import* a .pyo module. > $ echo "print(__file__)" > foo.py > $ python3.3 -O -m foo Since foo.py is in the current directory, I am not sure why you use '-m foo' instead of 'foo.py'. -m is for running a module somewhere on sys.path. > /home/marco/temp/foo.py > $ ls > foo.py __pycache__ > $ rm foo.py > $ mv __pycache__/foo.cpython-33.pyo foo.pyo > $ rm __pycache__ -r > $ ls > foo.pyo > # The following works in Python3.2, but not in 3.3 > $ python3.3 -O -m foo I would try just 'foo.pyo' in case the -m part is the problem. Also, the -O is sort of redundant, or perhaps interfering, since its usual effect to to say 'get and put, from and to the cache, .pyo instead of .pyc'. > /usr/local/bin/python3.3: No module named foo > > How come? Thanks in advance, Marco You might read some of http://bugs.python.org/issue12982 in particular, from http://bugs.python.org/issue12982#msg162814 "Indeed, since I posted last night, the pydev discussion has moved to the question of whether -O, __debug__, and .pyo as now defined are worth the nuisance they cause or whether some or all should be deprecated. (Docstring stripping for saving space could then be a separate tool.) --- Python interpreters exist to run Python code. The existence, persistence, and other details of compilation caches are version-dependent implementation details. Being able to execute from such caches without source present is also an implementation detail, and for CPython, it gets secondary support at best. (This is a compromise between full support and no support.)" -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 3.3 and .pyo files Marco <nameDOTsurname@gmail.com> - 2012-09-21 11:10 +0200
Re: Python 3.3 and .pyo files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-21 12:55 +0000
Re: Python 3.3 and .pyo files Marco <nameDOTsurname@gmail.com> - 2012-09-21 17:27 +0200
Re: Python 3.3 and .pyo files Terry Reedy <tjreedy@udel.edu> - 2012-09-21 22:46 -0400
Re: Python 3.3 and .pyo files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-22 13:21 +0000
Re: Python 3.3 and .pyo files Ramchandra Apte <maniandram01@gmail.com> - 2012-09-22 07:01 -0700
Re: Python 3.3 and .pyo files Terry Reedy <tjreedy@udel.edu> - 2012-09-22 18:54 -0400
Re: Python 3.3 and .pyo files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-27 02:25 +0000
csiph-web