.py and .pyc files in read-only directory

Chris Rebert clp2 at rebertia.com
Fri Oct 14 15:31:46 EDT 2011


On Fri, Oct 14, 2011 at 11:04 AM, Terry <twestley at gmail.com> wrote:
> I'm having a problem with my iPhone/iPad app, Python Math, a Python
> 2.7 interpreter. All the Python modules are delivered in what Apple
> calls the app bundle. They are in a read-only directory. This means
> that Python cannot write .pyc files to that directory. (I get a deny
> write error when doing this.) I tried using compileall to precompile
> all the modules, but now I get an unlink error because Python
> apparently wants to rebuild the .pyc files.

You can stop Python from trying to write .pyc files by using the
environment variable PYTHONDONTWRITEBYTECODE, the interpreter's -B
command line option, or by setting sys.dont_write_bytecode to True.

Cheers,
Chris



More information about the Python-list mailing list