Page MenuHomePhabricator

Add dependencies for Postgresql to Kubernetes container
Open, Stalled, NormalPublic


I am trying to start a Django server on Tool Labs and am running into an issue with the Postgresql libraries.

It was suggested to me that the container might not have access to the system package that is required to use psycopg2.

I am also still investigating if it a linking issue.

File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/models/", line 214, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/", line 211, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/", line 115, in load_backend
    return import_module('%s.base' % backend_name)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/importlib/", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/contrib/gis/db/backends/postgis/", line 2, in <module>
    from django.db.backends.postgresql.base import \
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/backends/postgresql/", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: cannot open shared object file: No such file or directory
unable to load app 0 (mountpoint='') (callable not found or import error)
mounting /data/project/commons-campaign-commander/www/python/src/ on /commons-campaign-commander
Traceback (most recent call last):
  File "/data/project/commons-campaign-commander/www/python/src/", line 7, in <module>
    app = get_wsgi_application()
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/core/", line 13, in get_wsgi_application
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/", line 27, in setup
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/apps/", line 78, in populate
    raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant

Event Timeline

Restricted Application added a project: Cloud-Services. · View Herald TranscriptMar 23 2017, 10:24 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
bd808 added a subscriber: bd808.Mar 26 2017, 6:50 PM

Why not switch to a pure python postgres driver like or ? Usage of postgres in tool labs is going to be a very uncommon thing. We have been attempting to keep the Docker images used for our Kubernetes deploy as small as possible.

bd808 triaged this task as Normal priority.Mar 26 2017, 6:50 PM
bd808 moved this task from Triage to Backlog on the Cloud-Services board.Mar 26 2017, 7:17 PM
Tobias1984 added a comment.EditedMar 26 2017, 8:17 PM

The postgis database backend of Django is based on psycopg2. Probably it would need to be re-implemented in py-postgresql. Not sure how much effort that would take. Will think about it or maybe look for another hosting solution.

bd808 moved this task from Backlog to Tools on the Cloud-Services board.Mar 26 2017, 10:48 PM
bd808 changed the task status from Open to Stalled.Jun 7 2017, 12:53 AM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptMar 26 2019, 5:31 PM