简体   繁体   English

我的代码无法识别`import sklearn`

[英]my code doesn't recognize `import sklearn`

I'm trying to install scikit-learn . 我正在尝试安装scikit-learn I installed numpy and scipy , and I installed using both pip install -U scikit-learn and conda install scikit-learn (just to be sure). 我安装了numpyscipy ,并且同时使用pip install -U scikit-learnconda install scikit-learn (请确保)。

However, once my code gets to a line like from sklearn import datasets - it throws an error: 但是,一旦我的代码到达from sklearn import datasets类的行from sklearn import datasets它就会引发错误:

 File "numpy.pxd", line 155, in init sklearn.utils.murmurhash 
(sklearn\utils\murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling

My code doesn't seem to recognize sklearn , although I know it is installed; 我的代码似乎无法识别sklearn ,尽管我知道它已安装; the only solutions I found on the web recommended on installing scipy - which I already have. 我在网上找到的唯一解决方案建议安装scipy我已经有了。

Any solutions? 有什么办法吗?

Since you have conda installed, a workaround would be creating a new environment. 由于已安装conda ,因此解决方法将是创建新环境。 For example: 例如:

conda create -n my_new_env python=3.5

Choose the right Python version for you. 选择适合您的Python版本。

Activate the environment. 激活环境。

On Windows: 在Windows上:

activate my_new_env

On Linux/Mac OS X: 在Linux / Mac OS X上:

source activate my_new_env

Now: 现在:

conda install scikit-learn

and start a new Python interpreter in this environment. 并在此环境中启动新的Python解释器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM