Using PL/Pythonu with virtualenv

∥☆過路亽.° 提交于 2019-12-11 01:36:45

问题


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?


回答1:


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'




回答2:


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.



来源:https://stackoverflow.com/questions/11019169/using-pl-pythonu-with-virtualenv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!