Search code examples
pythondjangomod-wsgipyc

Cannot find .pyc files for django/apache/mod_wsgi


I am running a web app on python2.7 with mod_wsgi/apache. Everything is fine but I can't find any .pyc files. Do they not get generated with mod_wsgi?


Solution

  • By default apache probably doesn't have any write access to your django app directory which is a good thing security wise.

    Now Python will byte recompile your code once every apache restart then cache it in memory.

    As it is a longlive process it is ok.

    Note: if you really really want to have those pyc, give a write access to your apache user to the source directory.

    Note2: This can create a hell lot of confusion when you start with manage.py a test instance shared by apache as this will create those pyc as root and will keep them if you then run apache despite a source code change.