I have problem in Postgres 16.2 with plpython procedure and library tabulate.
I created procedure:
CREATE OR REPLACE PROCEDURE dpl.__test_tabulate()
LANGUAGE plpython3u AS $plpy$
from tabulate import tabulate
plpy.info('%s' % tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
$plpy$;
But when I run it in psql, I get the error:
aisgamd1=# CALL dpl.__test_tabulate();
ERROR: TypeError: tabulate() got an unexpected keyword argument 'colalign'
CONTEXT: Traceback (most recent call last):
PL/Python function "__test_tabulate", line 4, in <module>
plpy.info('%s' % tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
PL/Python procedure "__test_tabulate"
aisgamd1=#
The my postgres runs on RHEL 8.9.
On the RHEL is python 3.9 installed (with 3.6 together).
When I run this procedure in python 3.9, it works:
# python
Python 3.9.18 (main, Sep 22 2023, 18:24:59)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tabulate import tabulate
>>> print(tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
----- ----
one two
three four
----- ----
But Postgres 16.2 use python 3.6, and there the procedure does not work. And when I run the procedure in RHEL python 3.6, it does not works too.
How do I force Postgres to use python 3.9 instead of 3.6 version?
Thanks
Michal
In Postgres:
CREATE OR REPLACE PROCEDURE dpl.__test_tabulate()
LANGUAGE plpython3u AS $plpy$
from tabulate import tabulate
plpy.info('%s' % tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
$plpy$;
But when I run it in psql, I get the error:
aisgamd1=# CALL dpl.__test_tabulate();
ERROR: TypeError: tabulate() got an unexpected keyword argument 'colalign'
CONTEXT: Traceback (most recent call last):
PL/Python function "__test_tabulate", line 4, in <module>
plpy.info('%s' % tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
PL/Python procedure "__test_tabulate"
aisgamd1=#
In RHEL:
# python
Python 3.9.18 (main, Sep 22 2023, 18:24:59)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tabulate import tabulate
>>> print(tabulate([["one", "two"], ["three", "four"]], colalign=("right",)))
----- ----
one two
three four
----- ----
Misudka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.