I have an old system that I’m trying to replicate. It is based on an old Debian Wheezy (7.1) system and uses Apache 2.2.22 and libapache2-mod-wsgi 3.3, in daemon mode, and Python 2.7.3. The WSGI application uses packages from a virtualenv, created with access to the global site-packages modules. It uses two subpackages from the same namespace package, that are installed by the system in different places:
repoze.who
, installed in/usr/lib/pymodules/python2.7/
repoze.lru
, installed in/usr/lib/python2.7/dist-packages/
My problem is that it does not work on the replicated system: the application fails to import repoze.who
. On the other hand, on the original system, it works file and successfully imports both subpackages.
I understand that it’s not supposed to work since, in normal configuration, Python does not expect a package to be split in several places.
I read the python import different subpackages with the same root packge name and different locations question and its answer. If I modify both repoze/__init__.py
files as suggested, it works fine on the replicated system.
But I checked both files on the original system, and they are empty.
I added a few print
instructions in the WSGI application, to investigate the original system. sys.path
looks fine and similar on both systems, with /usr/lib/python2.7/dist-packages
before /usr/lib/pymodules/python2.7
on both. Surprisingly, the repoze
package is imported from /usr/lib/pymodules/python2.7
on the original system, while it is imported from /usr/lib/python2.7/dist-packages
on the replicated system. Moreover, repoze.__path__
contains both locations on the original system, while it only contains /usr/lib/python2.7/dist-packages/repoze
on the replicated system.
Last but not least, if I run the virtualenv’s python interpreter on the original system, it fails to import the repoze.who
package while it imports repoze.lru
file, which looks like a normal behaviour. Hence, there must be something special with mod-wsgi or the application.
I guess something “clever” was done to allow the WSGI application to load both packages from different locations, but I have no idea what. Any suggestion is welcome.