Reputation: 539
I'm using my_db=# CREATE EXTENSION IF NOT EXISTS plpythonu SCHEMA pg_catalog VERSION '1.0';
query in PostgreSQL 11.5 installed on Ubuntu 19.10 to create plpythonu extension. But I faced following error:
ERROR: could not open extension control file "/usr/share/postgresql/10/extension/plpythonu.control": No such file or directory
For installing plpythonu package I used sudo apt-get update && apt-get install postgresql-plpython3
command and it successfully installed. Then, I checked /usr/share/postgresql
directory and there are 10 and 11 directories in my case. I googled for error and I found PostgreSQL: how to install plpythonu extension and Postgres database crash when installing plpython posts and followed the answers, but they didn't worked in my case. Also, I read about it in documentation in here Chapter 43. PL/Python - Python Procedural Language but still could not find a solution for solving the error and I can not create the plpythonu extension in database. Now, I wonder if I should remove or uninstall anything or there is something wrong with my PostgreSQL? Please guide me with steps I should follow to create the extension.
Upvotes: 0
Views: 3281
Reputation: 1313
looks you installed wrong version plpython3u on you postgresql 10.
You can try:
OS level installation:
update local repositary by
apt update
search supported plpython version for your database by
apt-cache search plpython
check the result, find right package for postgres 10 plpython3u, below is example list in my debian based postgres dockers container
postgresql-plpython3-10 - PL/Python 3 procedural language for PostgreSQL 10 postgresql-plpython3-10-dbgsym - debug symbols for postgresql-plpython3-10 postgresql-plpython3-11-dbgsym - debug symbols for postgresql-plpython3-11 postgresql-plpython3-12 - PL/Python 3 procedural language for PostgreSQL 12 postgresql-plpython3-12-dbgsym - debug symbols for postgresql-plpython3-12 postgresql-plpython3-13 - PL/Python 3 procedural language for PostgreSQL 13 postgresql-plpython3-13-dbgsym
- debug symbols for postgresql-plpython3-13
install the right package pg10 + plpython3u and not debug version by
apt install postgresql-plpython3-10
Postgresql Level installation & Configuration
1.connect to your postgresql 10 DB and create extension by
=# create extension plpython3u; CREATE EXTENSION
=# \dx List of installed extensions Name | Version | Schema | Description ------------+---------+------------+------------------------------------------- plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language plpython3u | 1.0 | pg_catalog | PL/Python3U untrusted procedural language (2 rows)
run first plpython3u function pymax by:
<DB name>=# CREATE FUNCTION pymax (a integer, b integer)
RETURNS integer
AS $$
if a > b:
return a
return b
$$ LANGUAGE plpythonu;
if eveything is OK, you has got first plpython3u function. Enjoy.
Note: you may need install python3 first by apt install python3
Upvotes: 2