Using PL/Pythonu with virtualenv

2019-07-17 01:42发布

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?

2条回答
乱世女痞
2楼-- · 2019-07-17 02:03

Answered over at https://stackoverflow.com/a/24892335/5430

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

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-17 02:22

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'

查看更多
登录 后发表回答