jfloff/pywFM

Path not set

JoshuaC3 opened this issue · 6 comments

Hi, trying the use this wrapper and I am getting the error

OSError                                   Traceback (most recent call last)
<ipython-input-1-6bd4815fa3b6> in <module>()
     16 target = [5, 3, 1, 4, 5, 1, 5]
     17 
---> 18 fm = pywFM.FM(task='regression', num_iter=5)
     19 
     20 # split features and target for train/test

/usr/local/lib/python3.5/dist-packages/pywFM/__init__.py in __init__(self, task, num_iter, init_stdev, k0, k1, k2, learning_method, learn_rate, r0_regularization, r1_regularization, r2_regularization, rlog, verbose, silent, temp_path)
    103         self.__libfm_path = os.environ.get('LIBFM_PATH')
    104         if self.__libfm_path is None:
--> 105             raise OSError("`LIBFM_PATH` is not set. Please install libFM and set the path variable (https://github.com/jfloff/pywFM#installing).")
    106 
    107     def run(self, x_train, y_train, x_test, y_test, x_validation_set=None, y_validation_set=None):

OSError: `LIBFM_PATH` is not set. Please install libFM and set the path variable (https://github.com/jfloff/pywFM#installing).

I followed the install instructions exactly, specifically making sure I did the export path part correctly. What might be going wrong here?

Just like its written in the Installing section, you need to set LIBFM_PATH with the path for your libfm binaries, eg:

export LIBFM_PATH=/home/libfm/bin/

I did this. I ran specifically
export LIBFM_PATH=/home/libfm/bin/
as you had said in the Installing section.

I then ran
pip install pywFM

I then opened up a Jupyter Notebook from a separate terminal. The code failed to run with the above error. This was my issue. I would have needed to set LIBFM_PATH again in any new terminal before running python or an IPython or Jupyter notebook. Maybe you could add this to the Install/Useage Instructions.

Many thanks.

According to a quick google that seems to be a Jupyter Problem. It seems that env variables are not sourced in Jupyter. Take a look at the following link for more information: jupyterhub/jupyterhub#330

Feel free to also post other links for future reference!

I tested this in the python terminal and it also did not work without having done export LIBFM_PATH=/home/libfm/bin/. I seems that LIBFM_PATH is not permanently saved. This is fine though now that I am aware of this :)

Well, that's environment vars 101: if you want to set you variables permanently you have to set them in the appropriate .profile file

Cheers!

environmental varibales can be setup from Jupyter via following

import sys,os,os.path

os.environ['LIBFM_PATH']=os.path.expanduser('your bin path')