0

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.

3
  • "ERROR: could not open extension control file "/usr/share/postgresql/10" You don't seem to be connected to a version 11 PostgreSQL server. Commented Jan 14, 2020 at 14:59
  • 1
    "psql" is not the database server, it is a client program. The version of "psql" does not need to match the version of the server it is connected to. Commented Jan 14, 2020 at 15:42
  • Following command shows the PostgreSQL version is different than psql version and your right.apps_mod=# SELECT version(); version PostgreSQL 10.10 (Ubuntu 10.10-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit (1 row). Then with above version of PostgreSQL what is wrong with database and creating plpythonu extension? What should I do to fix the above error? Commented Jan 14, 2020 at 15:52

1 Answer 1

2

looks you installed wrong version plpython3u on you postgresql 10.

You can try:

OS level installation:

  1. update local repositary by

    apt update

  2. search supported plpython version for your database by

    apt-cache search plpython

  3. 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
  1. 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

  1. check readness by

=# \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)

  1. 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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.