Cannot import scikits-learn even though it seems to be installed

前端 未结 4 1103
情书的邮戳
情书的邮戳 2021-01-01 10:06

Per the scikit-learn user guide, I installed scikit-learn using pip install -U scikit-learn.

So using pip search scikit-learn, I get this s

相关标签:
4条回答
  • 2021-01-01 10:47

    Got same problem, @Alan gave correct solution but hard way. Here are easy steps to resolve issue, as i am on mac osx, giving steps for same.

    Ameys-Mac-mini:~ amey$ python --version
    Python 2.7.2
    Ameys-Mac-mini:~ amey$ cd /Library/Python/2.7/site-packages/
    Ameys-Mac-mini:site-packages amey$ brew install gcc
    Ameys-Mac-mini:site-packages amey$ sudo pip install -t . numpy scipy scikit-learn 
    
    0 讨论(0)
  • 2021-01-01 10:47

    For future reference:

    easy_install -U statsmodels

    0 讨论(0)
  • 2021-01-01 10:48

    In my case, my python extension has installed all in

    /Library/Python/2.7/site-packages/ 
    

    After I use the command given by the official site

    pip install -U numpy scipy scikit-learn
    

    the scikit-learn package was actually installed in my

    /usr/local/lib/python2.7/site-packages
    

    So I copied all the packages in second to the first directory, then I can import the sklearn package.

    0 讨论(0)
  • 2021-01-01 10:57

    Thanks folks (see comment thread under the question)! It turns out that I have two versions of Python under my Mac's /Library/Frameworks/Python.framework directory tree: 2.7 (came with OSX) and 7.3 (installed by EPD Free).

    It turns out pip put scikit-learn under 2.7 when I really wanted it under 7.3.

    Changing directories to site-packages under the desired version of Python, and invoking pip install -t . {package-name} suffices to install package-name under the desired version of Python.

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