I would like plpython3u to use a virtual environment for python. I have seen some (old and not particularly clear) instructions for virtualenv at PostgreSQL PL/Python: call stored procedure in virtualenv. However I havent seen anything for python venv. Can this be done and if so, how can it be done? Thanks.
CCl.
If you only need one
venvenvironment for PL/Python, you can simply modifyExecStartin the PostggreSQL unit file to loadvenvactivatescript.Below is excerpted from the PostgreSQL 14 systemd unit file of PGDG YUM installation (My
venvls located at/var/lib/pgsql/plpython/).Note that you need to copy the unit file
postgresql-14.servicefrom/usr/lib/systemd/system/to/etc/systemd/system/and executesystemctl daemon-reloadto take effect.Then you can check
venvwith thepkg_resourcesmodule inside PL/Python anonymous block (I installpyyamlin myvenvenvironment).