module not found on ipython notebook

前端 未结 2 1422
醉酒成梦
醉酒成梦 2021-02-13 02:58

I have an ipython notebook which starts with

import sklearn

When I run it, I get :

ImportError: No module named sklearn


        
相关标签:
2条回答
  • 2021-02-13 03:24

    I was able to fix this error on Ubuntu by adding a cell to the top of the notebook appending the module directory to the path:

    import sys
    sys.path.append('/usr/lib/python2.7/dist-packages')
    

    The path to add can be found when running pip install <something>, (such as numpy) and it tells you where each package is installed or already exists.

    0 讨论(0)
  • 2021-02-13 03:24

    Is it possible that /usr/bin/python is actually a symlink?

    The better solution is that you should be running your ipython notebook from a virtualenv that contains all the modules that you need.

    0 讨论(0)
提交回复
热议问题