I need to import a 3rd party module inside my pl/python function. It seems pl/python uses an internal python that does not have any 3rd party modules.
I get this kind of error:
ERROR: PL/Python: PL/Python function "to_tsvector_luc" failed DETAIL: <type 'exceptions.ImportError'>: No module named lucene ********** Error ********** ERROR: PL/Python: PL/Python function "to_tsvector_luc" failed SQL state: XX000 Detail: <type 'exceptions.ImportError'>: No module named lucene
How do I install the module into pl/python, so that I can import it from inside my stored procedure code?
Installation. The PostgreSQL can be integrated with Python using psycopg2 module. sycopg2 is a PostgreSQL database adapter for the Python programming language.
pl/python has access to the all the modules that the normal Python interpreter would have as long as they are in the $PYTHONPATH
on the server (and the user that runs the postgres service). Does import lucene
work if you run it in the Python interpreter on the server?
If your module is installed somewhere else (e.g. not dist-packages etc.), then you would need to edit your /etc/postgresql/9.1/main/environment
(adjust to your PostgreSQL version) file on the server and add something like PYTHONPATH='<path to your module>'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With