Ошибка язык plpythonu не существует

In postgres 9.2 I am trying to create a python program that can be a trigger. I want to run an external program (an exe on the local disk) so I am using python to run it. When I try to create a simple program like this:

CREATE FUNCTION one ()
RETURNS int
AS $$
# PL/Python function body
$$ LANGUAGE plpythonu;

I get the error:

ERROR:  language "plpythonu" does not exist
HINT:  Use CREATE LANGUAGE to load the language into the database.

When I run:

CREATE LANGUAGE plpythonu

I get the error:

ERROR:  could not access file "$libdir/plpython2": No such file or directory

I am using Windows 7 and python 2.5 .

I have looked in many places but cannot find a solution.

Any ideas?

Craig Ringer's user avatar

Craig Ringer

308k77 gold badges690 silver badges779 bronze badges

asked Dec 31, 2012 at 22:03

Jim's user avatar

4

I have just solved this problem, literally a few days back. The solution is quite involved. Here it goes.

  1. Install python 3.2.* version only on your system.
  2. In Postgresql use the ‘CREATE LANGUAGE plpython3u’ command to install Python 3 language support. More often than not, it will give the following error «unable to load «…..\plpython3.dll» error 126. (Note if it installs correctly, no error will be displayed.)

  3. In case you get the above error, goto your python installation directory (default is C:\python32) and look for «python3.dll» in the DLL’s folder. Copy this file to your Postgresql ‘lib’ folder in the installation directory of Postgres (default is c:\program files\postgres\9.x\lib\»). Rename this copied file to python32.dll.

  4. Now run the ‘CREATE LANGUAGE plpython3u’ command again. It should work this time.

To verify, check out the pg_available_extensions view in the system tables of postgresql. The row containing plpython3u should have a version number in the ‘installed version’ column.

Note : This only works for plpython3u language. I do not know any similar process for plpython2u.

answered Feb 4, 2013 at 7:41

Raghavendra Kumar's user avatar

2

To resolve this for plpython3, it was necessary to:

  • Install Python 3.2
  • Run CREATE LANGUAGE plpython3u

Update: I’ve written a much better explanation here: https://stackoverflow.com/a/24218449/398670

Community's user avatar

answered Jan 11, 2013 at 2:33

Craig Ringer's user avatar

Craig RingerCraig Ringer

308k77 gold badges690 silver badges779 bronze badges

Postgres uses the ActiveState distros of Python. Most likely, your 2.5 is too outdated and Postgres cant load the plpython dll or didn’t install it because there was no suitable python. I think recent postgres is buil6 against Python3 not 2.x. You can look in the postgres lib directory for plpython3.dll to find out what you need.

answered Dec 31, 2012 at 22:16

jlujan's user avatar

jlujanjlujan

1,1887 silver badges10 bronze badges

14

I’m installed python 3.2(x64) y postgres 9.3 (x64)

Execute this code CREATE EXTENSION plpython3u

Do not forget to check the «installation-note.html» your version of postgresSQL there are specific python version for your postgresSQL

Zong's user avatar

Zong

6,1605 gold badges32 silver badges46 bronze badges

answered Jun 2, 2014 at 18:48

user3700545's user avatar

sorry for mining, but for all of those, who are looking for missing packet (in my case on Ubuntu 18.04):

sudo apt-get install -y postgresql-plpython3-10

and then:

create extension plpython3u;

answered Feb 26, 2021 at 9:08

Krzysztof Mochocki's user avatar

3

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 I get:

ERROR: language "plpythonu" does not exist

When I try to create the extension:

CREATE EXTENSION plpythonu

I get 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 a point at which PostgreSQL actually sees the available extensions. When I run:

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             | 

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!

questionto42's user avatar

questionto42

7,2054 gold badges57 silver badges90 bronze badges

asked Sep 29, 2014 at 1:31

Paul Angelno's user avatar

4

You’re using a PostgreSQL package from Bitnami, in /opt. It’s not clear if you installed this with apt-get or via an installer script/program, but in either case it’s not the same PostgreSQL as what’s in the Ubuntu postgresql package.

Installing postgresql-plpython won’t do you any good, because you’re installing PL/Python support for a different PostgreSQL install than the one you’re actually using.

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.

Otherwise, if you’re not too attached to using Bitnami’s PostgreSQL, you could use the recommended packages from http://apt.postgresql.org/ .

answered Sep 29, 2014 at 2:20

Craig Ringer's user avatar

Craig RingerCraig Ringer

308k77 gold badges690 silver badges779 bronze badges

4

for postgres 11.2 (Debian based) I needed to install:

apt-get update && apt-get install postgresql-plpython3-11

answered Apr 19, 2019 at 10:21

andilabs's user avatar

andilabsandilabs

22.2k14 gold badges115 silver badges151 bronze badges

5

I’m running Raspbian 10 (buster) / Linux raspberrypi 4.19.97-v7+ #1294 and ran the following commands to install PL/Python 3 on PostgreSQL 11.7.

  1. Identify which versions are available for install:
pi@raspberrypi:~/$ sudo apt-cache search ".*plpython3.*"
postgresql-plpython3-11 - PL/Python 3 procedural language for PostgreSQL 11
  1. sudo apt-get install postgresql-contrib postgresql-plpython3-11

  2. sudo systemctl start postgresql (or use enable to start this at every startup, see Getting started with PostgreSQL on Linux) on stand-alone Linux or sudo service postgresql start (on WSL2).

Else, you would get the error:

psql: error: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  1. sudo su - postgres

  2. psql

  3. CREATE EXTENSION plpython3u;

  4. Verify with command:

select * from pg_language;

questionto42's user avatar

questionto42

7,2054 gold badges57 silver badges90 bronze badges

answered Jun 2, 2020 at 11:19

Brian Blank's user avatar

3

In postgres 9.2 I am trying to create a python program that can be a trigger. I want to run an external program (an exe on the local disk) so I am using python to run it. When I try to create a simple program like this:

CREATE FUNCTION one ()
RETURNS int
AS $$
# PL/Python function body
$$ LANGUAGE plpythonu;

I get the error:

ERROR:  language "plpythonu" does not exist
HINT:  Use CREATE LANGUAGE to load the language into the database.

When I run:

CREATE LANGUAGE plpythonu

I get the error:

ERROR:  could not access file "$libdir/plpython2": No such file or directory

I am using Windows 7 and python 2.5 .

I have looked in many places but cannot find a solution.

Any ideas?

Craig Ringer's user avatar

Craig Ringer

308k77 gold badges690 silver badges779 bronze badges

asked Dec 31, 2012 at 22:03

Jim's user avatar

4

I have just solved this problem, literally a few days back. The solution is quite involved. Here it goes.

  1. Install python 3.2.* version only on your system.
  2. In Postgresql use the ‘CREATE LANGUAGE plpython3u’ command to install Python 3 language support. More often than not, it will give the following error «unable to load «…..\plpython3.dll» error 126. (Note if it installs correctly, no error will be displayed.)

  3. In case you get the above error, goto your python installation directory (default is C:\python32) and look for «python3.dll» in the DLL’s folder. Copy this file to your Postgresql ‘lib’ folder in the installation directory of Postgres (default is c:\program files\postgres\9.x\lib\»). Rename this copied file to python32.dll.

  4. Now run the ‘CREATE LANGUAGE plpython3u’ command again. It should work this time.

To verify, check out the pg_available_extensions view in the system tables of postgresql. The row containing plpython3u should have a version number in the ‘installed version’ column.

Note : This only works for plpython3u language. I do not know any similar process for plpython2u.

answered Feb 4, 2013 at 7:41

Raghavendra Kumar's user avatar

2

To resolve this for plpython3, it was necessary to:

  • Install Python 3.2
  • Run CREATE LANGUAGE plpython3u

Update: I’ve written a much better explanation here: https://stackoverflow.com/a/24218449/398670

Community's user avatar

answered Jan 11, 2013 at 2:33

Craig Ringer's user avatar

Craig RingerCraig Ringer

308k77 gold badges690 silver badges779 bronze badges

Postgres uses the ActiveState distros of Python. Most likely, your 2.5 is too outdated and Postgres cant load the plpython dll or didn’t install it because there was no suitable python. I think recent postgres is buil6 against Python3 not 2.x. You can look in the postgres lib directory for plpython3.dll to find out what you need.

answered Dec 31, 2012 at 22:16

jlujan's user avatar

jlujanjlujan

1,1887 silver badges10 bronze badges

14

I’m installed python 3.2(x64) y postgres 9.3 (x64)

Execute this code CREATE EXTENSION plpython3u

Do not forget to check the «installation-note.html» your version of postgresSQL there are specific python version for your postgresSQL

Zong's user avatar

Zong

6,1605 gold badges32 silver badges46 bronze badges

answered Jun 2, 2014 at 18:48

user3700545's user avatar

sorry for mining, but for all of those, who are looking for missing packet (in my case on Ubuntu 18.04):

sudo apt-get install -y postgresql-plpython3-10

and then:

create extension plpython3u;

answered Feb 26, 2021 at 9:08

Krzysztof Mochocki's user avatar

3

Hi @NyakudyaA! Thanks for your feedback. Python 2 is still the default version as of Postgres v11.2 — preferred by the Postgres Group over Python 3. Here is what I did to make Python 2 work:

  1. Clone the Github repository and change the Dockerfile as following:
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/postgresql.list'
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc -O- | apt-key add -

#-------------Application Specific Stuff ----------------------------------------------------

# Install Phyton 2.7
RUN apt-get update; apt-get install -y python2.7 python-pip libreadline-dev zlib1g-dev

# We add postgis as well to prevent build errors (that we dont see on local builds)
# on docker hub e.g.
# The following packages have unmet dependencies: -- including postgresql-plpython-11
RUN apt-get update; apt-get install -y postgresql-client-11 postgresql-common postgresql-11 postgresql-11-postgis-2.5 postgresql-11-pgrouting netcat postgresql-plpython-11
  1. I created the image using:
docker build -t <your-image-name> .
  1. I ran the container using:
docker run -d --name "<your-container-name>" --security-opt apparmor=unconfined -p 25432:5432 -e POSTGRES_USER=<username> -e POSTGRES_PASS=<password> -e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,plpythonu,plpgsql -v /data/postgres-data:/var/lib/postgresql -t <your-image-name>

(note that you must have created the host directory /data/postgres-data beforehand)

  1. I logged into the Postgres database
docker exec -it <your-container-name> /bin/bash

and enabled Python: (which is PER DATABASE)

su postgres
psql
CREATE database <database-name>;
\c <database-name>;
CREATE PROCEDURAL LANGUAGE 'plpythonu' HANDLER plpython_call_handler;
UPDATE pg_language SET lanpltrusted = true WHERE lanname LIKE 'plpythonu';

and voilá you are able to use Python as a language in Postgres 11.2. If you have many database you do not want to repeat the last step many times (in this case you can assign plpythonu to «template1» and Python will be available for all databases). Hope this will help someone else as it took some time to put these pieces together.

I used this setup to migrate a Postgres 9.5 database (running in a bare metal server) to Postgres 11.2 in a Docker contrainer.

В postgres 9.2 я пытаюсь создать программу python, которая может быть триггером. Я хочу запустить внешнюю программу (exe на локальном диске), поэтому я использую python для ее запуска. Когда я пытаюсь создать простую программу, например:

CREATE FUNCTION one ()
RETURNS int
AS $$
# PL/Python function body
$$ LANGUAGE plpythonu;

Я получаю сообщение об ошибке:

ERROR:  language "plpythonu" does not exist
HINT:  Use CREATE LANGUAGE to load the language into the database.

Когда я запускаю:

CREATE LANGUAGE plpythonu

Я получаю сообщение об ошибке:

ERROR:  could not access file "$libdir/plpython2": No such file or directory

Я использую Windows 7 и python 2.5.

Я смотрел во многих местах, но не могу найти решение.

Любые идеи?

Поделиться

Источник

4 ответа

Я только что решил эту проблему, буквально несколько дней назад. Решение довольно востребовано. Вот оно.

  • Установите версию python 3.2. * только в вашей системе.
  • В Postgresql используйте команду ‘CREATE LANGUAGE plpython3u’ для установки поддержки языка Python 3. Чаще всего это приведет к ошибке «невозможно загрузить»….. \plpython3.dll «ошибка 126. (Обратите внимание, что если она установлена ​​правильно, ошибка не будет отображаться.)

  • Если вы получили вышеуказанную ошибку, перейдите в свой каталог установки python (по умолчанию C:\python32) и найдите «python3.dll» в папке DLL. Скопируйте этот файл в папку Postgresql ‘lib’ в установочном каталоге Postgres (по умолчанию это c:\program files\postgres\9.x\lib\»). Переименуйте этот скопированный файл в python32.dll.

    /li >

  • Теперь запустите команду CREATE LANGUAGE plpython3u. Он должен работать на этот раз.

Чтобы проверить, просмотрите представление pg_available_extensions в системных таблицах postgresql. Строка, содержащая plpython3u, должна иметь номер версии в столбце «установленная версия».

Примечание. Это работает только для языка plpython3u. Я не знаю никакого подобного процесса для plpython2u.

Raghavendra Kumar

Поделиться

Postgres использует дистрибутивы ActiveState Python. Скорее всего, ваш 2.5 слишком устарел, и Postgres не может загрузить dll plpython или не установить его, потому что не было подходящего python. Я думаю, что последние postgres — buil6 против Python3, а не 2.x. Вы можете посмотреть в каталоге postgres lib для plpython3.dll, чтобы узнать, что вам нужно.

jlujan

Поделиться

Я установлен python 3.2 (x64) y postgres 9.3 (x64)

Выполните этот код CREATE EXTENSION plpython3u

Не забудьте проверить «installation-note.html» в вашей версии postgresSQL, есть определенная версия python для вашего postgresSQL

user3700545

Поделиться

Ещё вопросы

  • 0Разделительные функции на угловые
  • 0Как я могу избежать семантической связи для создания многоразового движка дисплея?
  • 1Распечатать список в указанном диапазоне Python
  • 0Отправка даты и времени из Android в MySQL
  • 0Как выровнять навигационную панель по нижней части окна без зазора между кнопками и краем окна
  • 0Как считать выбранные строки в SQL
  • 1python selenium firefox, специальный символ @ для всплывающей аутентификации
  • 0Selenium IDE Xpath против веб-драйвера Xpath
  • 1Использование стандартного / выходного потока в качестве строки ввода / вывода
  • 1какими должны быть размеры матрицы Q в открытой среде для Q-обучения
  • 0scanf может читать только 3 символа в 5-позиционном массиве символов
  • 1Отображение всего пути каждого листа на дереве
  • 1Не удалось установить MultiHandleSliderExtender для свойства MultiHandleSliderTargets
  • 0Математика: Хранение 11 значений в 1
  • 1Recycler view не отвечает на клики
  • 1Как получить только дату или время только в реакции на нативный
  • 1Странное поведение в аргументе javascript внутри глобального объекта
  • 1Как выбрать между различными условиями, зависящими от другой переменной
  • 1Захватите строку фрейма данных pandas на основе значения в этой строке и нескольких предыдущих строк
  • 0MySQL / Hibernate SQLQuery, как привести unsigned int (10) к smallint?
  • 0Промежуточное программное обеспечение Angular Resource для отслеживания реакции
  • 0Установите PK из аннотаций ManyToMany в сущности Doctrine2
  • 1Панды фильтруют или удаляют строки в нескольких условиях
  • 1Что касается неизменяемой коллекции
  • 0Изменить css объекта, используя jquery, итерируя по массиву объектов
  • 0Что делать, если уравнение возвращает nan в качестве ответа?
  • 0Запустите JavaScript на Btn, но не контейнер
  • 0Нелокальный сервер: управление корневым каталогом для поддержки короткого URL
  • 1Полный список цветов Excel с xlsxwriter
  • 0Последовательность печати шаблона из 3 символов
  • 0Href vs select box
  • 0Ява: Разбор Json правильно?
  • 1Статические кнопки под ScrollView с динамическим расположением таблиц внутри
  • 0Как использовать COUNT в этом SQL-запросе?
  • 0Uncaught TypeError: Невозможно прочитать свойство ‘innerHTML’ для пустых функций. Js: 29 changeNameToLetters functions.js: 29 onclick
  • 1Python selenium ждет загрузки страницы без условия
  • 0Ошибка msvcr110d.dll! memcpy при тестировании структур и массивов
  • 0Могу ли я объединить эти вызовы g ++ в один?
  • 0Определение правил стиля для списка навигации (css)
  • 1Фоновые геозоны действительно работают на Android 8+?
  • 1Как выбрать тот же вариант, который был выбран на другой странице
  • 1Полимер служит для изменения обслуживаемых файлов JavaScript для Internet Explorer 11. Как заставить его работать на другом веб-сервере?
  • 1Python ctypes: структура с инициализацией битовых полей
  • 1Возможно ли использовать `ffmpeg.exe` на сервере общего хостинга?
  • 1Лучший способ создать этот класс Locus
  • 0Обновление JQuery до более новой версии, но какой?
  • 1python joblib & random walk — выполнение планирования [CONCURRENT] -процесса
  • 1Java: изменить значение объекта без изменения всех ссылок
  • 0Как создать URL api.ai моего агента в диалоговом окне (api.ai) и использовать этот URL API в PHP для хранения входных данных пользователя в базе данных MYSQL
  • 0Проблема с кодировкой Facebook API

Сообщество Overcoder

Понравилась статья? Поделить с друзьями:
  • Ошибки 0302 и 0303
  • Ошибка ютуб на телевизоре сони бравиа
  • Ошибка языка на латинском
  • Ошибка ютуб на телевизоре действие запрещено
  • Ошибка юстировки 104 топаз