Question

I'm trying to install Multicorn extension on PostgreSQL 9.3.3, but the problem I have that this extension only works with Python 2.7 or 3.3 whereas default version of python on my OS (Centos 6.5) is 2.6 and I can't change it without breaking the whole system.

I've installed python 2.7 alongside the default version and compiled Multicorn extension from source changing python references/paths in makefile to python 2.7, however I'm having trouble using the extension in Postgres.

Create extension command works just fine:

CREATE EXTENSION multicorn;

Creating the server, however fails:

CREATE SERVER csv_srv foreign data wrapper multicorn options (wrapper 'multicorn.csvfdw.CsvFdw');
ERROR:  Error in python: ImportError
DETAIL:  No module named multicorn

Is there a fix for this or at least a hint what to look for?

My assumption is that even though the extension itself was compiled with references to python 2.7 and all the files copied to the right folder /usr/local/lib/python2.7/dist-packages/multicorn-1.0.2-py2.7-linux-x86_64.egg/multicorn, PostgreSQL itself still uses the system default python 2.6 version and therefor fails to load the module. Is there any way to override python version that Postgres uses? Would that solve the problem?

Was it helpful?

Solution

You'll need to recompile PL/Python against Python 2.7.

Right now PL/Python will keep using Python 2.6. They aren't binary compatible and have separate sonames, libpython2.7.so and libpython2.6.so. So just changing the PATH and LD_LIBRARY_PATH will do nothing.

I would do this by downloading the PostgreSQL SRPM, modifying the spec file so it targets python 2.7, and rebuilding the RPMs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top