Search This Blog

Sunday, January 31, 2016

plpythonu + numpy and other modules - on a linux server (in this case a Raspberry Pi)

Setting up some plpython functions inside a PostgreSQL database on Linux is great...

sudo apt-get install postgresql-contrib postgresql-plpython    (with correct version numbers added)


and python module installations

pip install numpy

Test it in Python 

------------------
import numpy
print (numpy.e)


However on creating a plpython2u function the error msg report numpy couldn't be found ??

After much searching and looking to add the path of the user that installed the module - the easiest fix was to go back to the server (Rasp Pi2 in this case) and switch to the postgresql user

su postgres
{answer password prompt}

then do                    pip install numpy
also in this case        pip install nltk
then run  python as this user (postgres)

import nltk
nltk.download()
{select all - wait to download - close dialogue box}

Now the plpython2u modules that the postgres user sees has all the necessary data files to work properly...


No comments: