本文介绍了即使似乎已安装,也无法导入scikits-learn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据scikit-learn用户指南,我使用pip install -U scikit-learn安装了scikit-learn.

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

因此,使用pip search scikit-learn,我会得到以下搜索结果:

So using pip search scikit-learn, I get this search result:

scikit-learn - A set of python modules for machine learning and data mining
INSTALLED: 0.12.1 (latest)

但是当我进入Python并尝试import sklearn时,我得到了ImportError: No module named sklearn.这确实应该已经奏效.

But when I go into Python and try to import sklearn, I get an ImportError: No module named sklearn. This really should have just worked.

我在配备NumPy 1.6.1和SciPy 0.10.1的Mac OS 10.6.8上使用Enthought的Python(2.7.3)的免费发行版.是的,我知道scikit-learn附带了EPD Free,但是pip应该已经升级了我的版本,以便我可以实际使用scikit-learn.

I am using Enthought's free distribution of Python (2.7.3) on a Mac OS 10.6.8 with NumPy 1.6.1 and SciPy 0.10.1. Yes, I'm aware that EPD Free comes with scikit-learn but pip should have upgraded my version so that I can actually use scikit-learn.

推荐答案

谢谢大家(请参阅问题下方的评论主题)!事实证明,我在Mac的/Library/Frameworks/Python.framework目录树下有两个版本的Python:2.7(随OSX一起提供)和7.3(由EPD Free安装).

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).

事实证明,pip当我真的希望scikit-learn低于7.3时,将scikit-learn置于2.7以下.

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

在所需的Python版本下将目录更改为站点程序包,并调用pip install -t . {package-name}在所需的Python版本下安装程序包名称即可.

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.

这篇关于即使似乎已安装,也无法导入scikits-learn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 00:13