PostgreSQL:如何安装 plpythonu 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26091390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PostgreSQL: how to install plpythonu extension
提问by Paul Angelno
I'm running PostgreSQL 9.3.1 on Ubuntu 12.04.4. I'd like to use the plpython language extension but I get an error when I try to use it:
我在 Ubuntu 12.04.4 上运行 PostgreSQL 9.3.1。我想使用 plpython 语言扩展,但是当我尝试使用它时出现错误:
ERROR: language "plpythonu" does not exist
ERROR: language "plpythonu" does not exist
When I try to create the extension:
当我尝试创建扩展时:
CREATE EXTENSION plpythonu
CREATE EXTENSION plpythonu
...I get the error:
ERROR: could not access file "$libdir/plpython2": No such file or directory
...我收到错误:
ERROR: could not access file "$libdir/plpython2": No such file or directory
After much searching and digging through blog posts I've tried installing additional packages and have copied all the plpython files from /usr/share/postgresql/9.1/extension to /opt/bitnami/postgresql/share/extension where PostgreSQL seems to be looking for them. That at least got me to where PostgreSQL sees the available extensions. When I run:
经过大量搜索和挖掘博客文章后,我尝试安装其他软件包并将所有 plpython 文件从 /usr/share/postgresql/9.1/extension 复制到 PostgreSQL 似乎正在寻找的 /opt/bitnami/postgresql/share/extension为他们。这至少让我看到了 PostgreSQL 看到可用扩展的地方。当我运行时:
select name, default_version, installed_version from pg_available_extensions where name like 'plpy*'
select name, default_version, installed_version from pg_available_extensions where name like 'plpy*'
I get :
我得到:
name | default_version | installed_version
------------+-----------------+-------------------
plpython2u | 1.0 |
plpython3u | 1.0 |
plpythonu | 1.0 |
name | default_version | installed_version
------------+-----------------+-------------------
plpython2u | 1.0 |
plpython3u | 1.0 |
plpythonu | 1.0 |
There are still no plpython libraries that I can see in /opt/bitnami/postgresql/lib. Can anybody help me get through remaining steps to make the extension work? Thanks in advance!
在 /opt/bitnami/postgresql/lib 中仍然没有我可以看到的 plpython 库。任何人都可以帮助我完成剩余的步骤以使扩展工作?提前致谢!
采纳答案by Craig Ringer
You're using a PostgreSQL package from Bitnami, in /opt. It's not clear if you installed this with apt-getor via an installer script/program, but in either case it's not the same PostgreSQL as what's in the Ubuntu postgresqlpackage.
您正在使用来自 Bitnami 的 PostgreSQL 包,在/opt. 不清楚您apt-get是使用安装程序脚本/程序还是通过安装程序脚本/程序安装了它,但在任何一种情况下,它都与 Ubuntupostgresql软件包中的 PostgreSQL 不同。
Installing postgresql-plpythonwon't do you any good, because you're installing PL/Python support for a different PostgreSQL install than the one you're actually using.
安装postgresql-plpython对您没有任何好处,因为您正在为与实际使用的 PostgreSQL 安装不同的 PostgreSQL 安装安装 PL/Python 支持。
You'll need to use the same installation method you originally used to install the Bitnami PostgreSQL to add PL/Python support, if it's available. It might not be provided by Bitnami.
您需要使用最初用于安装 Bitnami PostgreSQL 的相同安装方法来添加 PL/Python 支持(如果可用)。它可能不是由 Bitnami 提供的。
Otherwise, if you're not too attached to using Bitnami's PostgreSQL, you could use the recommended packages from http://apt.postgresql.org/.
否则,如果您不太喜欢使用 Bitnami 的 PostgreSQL,您可以使用来自http://apt.postgresql.org/的推荐包。
回答by andilabs
for postgres 11.2(Debian based) I needed to install:
对于postgres 11.2(基于 Debian)我需要安装:
apt-get update && apt-get install postgresql-plpython3-11

