Using PL/Pythonu with virtualenv
Asked Answered
C

2

2

I am writing function in postgres in python using the PL/Pythonu extension in postgres. I would like postgres to use my virutal environment (I am using virtualenv) instead of the global install. How do I go about doing this?

Catania answered 13/6, 2012 at 16:21 Comment(0)
C
4

As it turns out, one must add the path to where the libraries are found to the PYTHONPATH environment variable in postgres. Don't forget to quote your value eg:

PYTHONPATH='path to libraries'

Catania answered 13/6, 2012 at 16:34 Comment(1)
As described in https://mcmap.net/q/430104/-postgresql-pl-python-call-stored-procedure-in-virtualenv/217844, this only seems to work in certain OSs. Ideally, Postgres should have a VIRTUALENV configuration setting.Righteousness
E
2

Answered over at https://mcmap.net/q/430104/-postgresql-pl-python-call-stored-procedure-in-virtualenv

tl;dr - exec activate_this.py inside plpython function will set python interpretor for the life of the postgresql session.

Englis answered 22/7, 2014 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.