0

I have a Ubuntu 18.04 with Postgres 10 server running Python 3.5.2, PL/Python function works very well.

How can I upgrade PL/Python to 3.8.0

I used pyenv to install 3.8.0 under user 'postgres', I checked python version already 3.8.0, I even updated /etc/postgresql/10/main/environment to

PYTHONPATH= '/var/lib/postgresql/.pyenv/shims/python3'

But when I run PL/Python function

CREATE FUNCTION ptest ()
  RETURNS text
AS $$
  import sys
  return sys.version
$$ LANGUAGE plpython3u;

The result still 3.5.2

2
  • Did you restart postgres after making the change? Commented Dec 9, 2019 at 16:24
  • yes, I did restart postgres Commented Dec 9, 2019 at 16:29

2 Answers 2

1

PostgreSQL's plpython extension needs to be compiled against the correct python header files. I doubt the header files are binary compatible between python 3.5 and 3.8. You will either need to recompile the PostgreSQL extension (or all of PostgreSQL) yourself, or find a package which ships the correctly compiled packages (which I doubt you will find).

The simple answer is, "don't do this". Why do you want to do this? If I were willing to build my own against a bleeding edge python, I would probably be doing it with a bleeding edge PostgreSQL, not the two year old version.

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

Comments

0

To answer the question why.... Two Reasons:

  1. Python 3.5 is EOL - https://www.python.org/downloads/release/python-350/
  2. Some modules need > 3.5

I agree that you shouldn't "force" an upgrade if it's not supported by the Postgresql - PL/Python team yet.

To work around this... I've seen some folks use virtual environments inside of PL/Python. Trying to avoid going that route if I can, rather way for direct support from the Postgresql PL/Python team.

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.