Re: How to control which Python interpreter Postgres uses?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We haven't moved to venvs yet here, so was trying to override the default Python interpreter file that postgre will use.

I did some more research and I can't see any way to adjust this behavior without compiling postgres from source, as Tom mentioned.

Here is an article from someone else with the same problem as me, solved by supplying proper configure flags during compilation:




From: Wells Oliver <wells.oliver@xxxxxxxxx>
Sent: Monday, November 1, 2021 5:08 PM
To: Ni Ne <nineoften@xxxxxxxxxxx>
Cc: Tom Lane <tgl@xxxxxxxxxxxxx>; pgsql-admin@xxxxxxxxxxxxxxxxxxxx <pgsql-admin@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: How to control which Python interpreter Postgres uses?
 
Apologies if I'm misunderstanding, but you can specify a virtual env (so any interpreter) as we did here:

CREATE FUNCTION slack (msg text)
    RETURNS boolean
AS $$
    hook = 'https://...'
    activate_this = '/opt/python/env/bin/activate_this.py'
    exec(open(activate_this).read(), dict(__file__=activate_this))
    from slack_sdk.webhook import WebhookClient
    import ssl
    ssl_context = ssl.create_default_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE
    webhook = WebhookClient(hook, ssl=ssl_context)
    webhook.send(text=msg)
    return True
$$ LANGUAGE plpython3u;




On Mon, Nov 1, 2021 at 3:06 PM Ni Ne <nineoften@xxxxxxxxxxx> wrote:
Would I recompile the plpython package or postgres itself?


From: Tom Lane <tgl@xxxxxxxxxxxxx>
Sent: Monday, November 1, 2021 4:03 PM
To: Ni Ne <nineoften@xxxxxxxxxxx>
Cc: pgsql-admin@xxxxxxxxxxxxxxxxxxxx <pgsql-admin@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: How to control which Python interpreter Postgres uses?
 
Ni Ne <nineoften@xxxxxxxxxxx> writes:
> How can I adjust my postgres settings to tell it which Python interpreter binary to use?

You'd have to recompile plpython against the particular libpython
you want to use.

                        regards, tom lane


--

[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux