jfloff / pywFM

pywFM is a Python wrapper for Steffen Rendle's factorization machines library libFM
https://pypi.python.org/pypi/pywFM
MIT License
250 stars 43 forks source link

problem of running in jupyter notebook #18

Closed kkhuang1990 closed 7 years ago

kkhuang1990 commented 7 years ago

I followed the instructions as you wrote on the github and can successfully run the test codes. however, I met the following error when running in my jupyter notebook


OSError Traceback (most recent call last)

in () 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/python2.7/dist-packages/pywFM/__init__.pyc in __init__(self, task, num_iter, init_stdev, k0, k1, k2, learning_method, learn_rate, r0_regularization, r1_regularization, r2_regularization, rlog, verbose, seed, silent, temp_path) OSError: `LIBFM_PATH` is not set. Please install libFM and set the path variable (https://github.com/jfloff/pywFM#installing). actually I have already set the LIBFM_PATH in my ~/.bashrc file as this: export LIBFM_PATH=$HOME/local/libfm/bin I don't know why the jupyter notebook cannot find this path
jfloff commented 7 years ago

Hello,

I had a previous issue regarding this (#11), and it seems Jupyter-specific problem: https://github.com/jupyterhub/jupyterhub/issues/330

As some hints, you can either try exporting into .profile, or you could also set it directly using Jupyter instructions: http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-env

When you find a solution, please report back! 👍

kkhuang1990 commented 7 years ago

thanks, after restarting the jupyter notebook, it works for me


黄 凱凱 (D2) Kaikai HUANG (D2) 東京大学 大学院情報理工学系研究科 知能機械情報学専攻 原田牛久研究室 E2-81C1 The University of Tokyo Graduate School of Information Science and Technology Dept. Mechano-Informatics Harada-Ushiku Lab. E2-81C1 Phone: 080-9640-2628 E-mail: huang@mi.t.u-tokyo.ac.jp

2017-06-22 1:21 GMT+09:00 João Ferreira Loff notifications@github.com:

Hello,

I had a previous issue regarding this (#11 https://github.com/jfloff/pywFM/issues/11), and it seems Jupyter-specific problem: jupyterhub/jupyterhub#330 https://github.com/jupyterhub/jupyterhub/issues/330

As some hints, you can either try exporting into .profile, or you could also set it directly using Jupyter instructions: http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-env

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfloff/pywFM/issues/18#issuecomment-310131683, or mute the thread https://github.com/notifications/unsubscribe-auth/AOOuYazD3GG-S7T91f_gs3qSGvT5ReHLks5sGUMlgaJpZM4OA5EH .

jfloff commented 7 years ago

Did you change anything? Or just a simple reload of jupyter worked? I'm assuming with the reload it started loading the new set of env variables that were on the bashrc (similar to when it happens to consoles that are open while you change .bashrc). Was that it?

kkhuang1990 commented 7 years ago

Actually I have made two modifications. (1) add this line to ~/.bash_profile.(the path should he the directory where you installed your libfm into) export LIBFM_PATH=$HOME/local/libfm/bin (2) add the following settings to ~/.jupyter/jupyter_notebook_config.py for var in os.environ: c.Spawner.env_keep.append(var) It may also work if you only append the LIBFM_PATH to env_keep. I am not sure. For completeness, I add all path variables

Then I restart the jupyter, It works


黄 凱凱 (D2) Kaikai HUANG (D2) 東京大学 大学院情報理工学系研究科 知能機械情報学専攻 原田牛久研究室 E2-81C1 The University of Tokyo Graduate School of Information Science and Technology Dept. Mechano-Informatics Harada-Ushiku Lab. E2-81C1 Phone: 080-9640-2628 E-mail: huang@mi.t.u-tokyo.ac.jp

2017-06-22 18:41 GMT+09:00 João Ferreira Loff notifications@github.com:

Did you change anything? Or just a simple reload of jupyter worked? I'm assuming with the reload it started loading the new set of env variables that were on the bashrc (similar to when it happens to consoles that are open while you change .bashrc). Was that it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfloff/pywFM/issues/18#issuecomment-310330416, or mute the thread https://github.com/notifications/unsubscribe-auth/AOOuYRwfuGJQ0jLiNTCdj0DpCMQfq0w1ks5sGja0gaJpZM4OA5EH .

jfloff commented 7 years ago

Thank you for the feedback! Soon I'll update the README with a link to this issue for future reference. :)

zhenv5 commented 7 years ago

Traceback (most recent call last): File "factorization_machine.py", line 18, in fm = pywFM.FM(task='regression', num_iter=5) File "/anaconda2/lib/python2.7/site-packages/pywFM/init.py", line 122, in init raise OSError("libFM is not checked out to the correct commit." OSError: libFM is not checked out to the correct commit.(https://github.com/jfloff/pywFM#installing).

When I tried to run the demo code, I met above errors.

jfloff commented 7 years ago

Did you follow all the steps from https://github.com/jfloff/pywFM#installing ?

LLLLucensus commented 4 years ago

Actually I have made two modifications. (1) add this line to ~/.bash_profile.(the path should he the directory where you installed your libfm into) export LIBFM_PATH=$HOME/local/libfm/bin (2) add the following settings to ~/.jupyter/jupyter_notebook_config.py for var in os.environ: c.Spawner.env_keep.append(var) It may also work if you only append the LIBFM_PATH to env_keep. I am not sure. For completeness, I add all path variables Then I restart the jupyter, It works

I didn't find jupyter_notebook_config.py but found a empty file named jupyter_notebook_config.json. Is it a file created by yourself?