简体   繁体   中英

my code doesn't recognize `import sklearn`

I'm trying to install 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).

However, once my code gets to a line like from sklearn import datasets - it throws an error:

 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; the only solutions I found on the web recommended on installing scipy - which I already have.

Any solutions?

Since you have conda installed, a workaround would be creating a new environment. For example:

conda create -n my_new_env python=3.5

Choose the right Python version for you.

Activate the environment.

On Windows:

activate my_new_env

On Linux/Mac OS X:

source activate my_new_env

Now:

conda install scikit-learn

and start a new Python interpreter in this environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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