如何为 postgres 安装 plpython?

how to install plpython for postgres?

我有 postgres 镜像:https://hub.docker.com/_/postgres 我正在尝试使用以下命令创建 python 扩展:

create extension plpythonu

但失败并显示错误:

psql:/docker-entrypoint-initdb.d/init.sql:1: ERROR:  could not open extension control file "/usr/share/postgresql/12/extension/plpythonu.control": No such file or directory

在我的 Dockerfile 中,我尝试安装包:

FROM postgres
RUN apt-get update -y
RUN apt install postgresql-plpython3-12

我收到错误:


Unable to locate package postgresql-plpython3-12

如何扩展 postgresql 以便我可以使用 python?

我找到了将 plpython3 安装到我的 postgres 容器中的解决方案

FROM postgres

RUN apt-get update
RUN apt-get -y install python3 postgresql-plpython3-12
COPY pg-setup-scripts/init.sql /docker-entrypoint-initdb.d

然后在入口点脚本中


create extension plpython3u;