Re: Changing Pl/Python default interpreter

From: Colin Brisson <colibrisson(at)gmail(dot)com>
To: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Changing Pl/Python default interpreter
Date: 2018-12-15 08:53:34
Message-ID: CAHgu9=8Rbnqgp=qCjFXVRRpVaRdMGeDU70Ftk4Y8CbHigEMz+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Tom,

Thank you for your answer. Postgre's Ubuntu package is great, both Python 2
and 3 are supported out of the box. However, I would like to use virtual
environments instead of global install.

I have found a couple of solutions but none of them are really satisfactory:

- Recompile Postgre from source with the PYTHON variable pointing to
anaconda.
- Activate virtualenv inside the default interpreter by using
activate_this.py (https://gist.github.com/dmckeone/69334e2d8b27f586414a)
- Set PYTHONPATH inside Postgre environment file (not compatible with
Anaconda).

Regards,

Colin

On Sat, Dec 15, 2018 at 9:52 AM Colin Brisson <colibrisson(at)gmail(dot)com> wrote:

> Hi Tom,
>
> Thank you for your answer. Postgre's Ubuntu package is great, both Python
> 2 and 3 are supported out of the box. However, I would like to use virtual
> environments instead of global install.
>
> I have found a couple of solutions but none of them are really
> satisfactory:
>
>
> - Recompile Postgre from source with the PYTHON variable pointing to
> anaconda.
> - Activate virtualenv inside the default interpreter by using
> activate_this.py (https://gist.github.com/dmckeone/69334e2d8b27f586414a
> ).
> - Set PYTHONPATH inside Postgre environment file (not compatible with
> Anaconda).
>
>
> Regards,
>
> Colin
>
>
> On Fri, Dec 14, 2018 at 9:42 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Colin Brisson <colibrisson(at)gmail(dot)com> writes:
>> > I'm running PostgreSQL 10.6 (Ubuntu 10.6-0ubuntu0.18.10.1) with
>> Pl/Python.
>> > Everything is working fine but I would like to change the default
>> > interpreter used by Pl/Python (without recompiling Postgre from
>> scratch).
>> > The docs say that if the PYTHON environment variable wasn't set during
>> > compilation, Pl/Python use any version it found. I wrote a small script
>> and
>> > I found which interpreter Pl/Python is using by default. Now I would
>> like
>> > to modify the symlink it uses to run Python -- I'm just assuming it's a
>> > symlink but maybe I'm wrong. The problem is that I tried to modify all
>> > python executables in /usr/bin but it didn't change Pl/Python default
>> > behavior. Does anyone know where I can find which file Pl/Python use to
>> run
>> > Python? Is there a better approach to change the default interpreter?
>>
>> plpython loads the relevant libpython.so, it doesn't invoke the "python"
>> executable. I do not think you can get it to use a different-version
>> libpython without recompiling. It will *certainly* not work to sub in
>> python 3.x for python 2.x or vice versa without a recompile, if that's
>> what you were hoping for, because some of the library APIs changed.
>>
>> regards, tom lane
>>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Viorel Tabara 2018-12-23 19:49:55 ahead of time compiling in PostgreSQL?
Previous Message Tom Lane 2018-12-14 20:42:00 Re: Changing Pl/Python default interpreter