hckjj
hckjj

Reputation: 21

Scikit-learn installation: "ImportError: No module named sklearn"

I've been trying my hand at machine learning and I've installed scikit-learn through anaconda, but when I try to import from sklearn, my interpreter gives me an ImportError. When I try

python setup.py install

in my site-packages/sklearn directory, I get this error:

creating build/temp.macosx-10.5-x86_64-3.5
creating build/temp.macosx-10.5-x86_64-3.5/src
creating build/temp.macosx-10.5-x86_64-3.5/src/libsvm
compile options: '-I/Users/jj/anaconda3/lib/python3.5/site-packages/numpy/core/include -c'
g++: src/libsvm/libsvm_template.cpp
clang: error: no such file or directory: 'src/libsvm/libsvm_template.cpp'
clang: error: no input files
clang: error: no such file or directory: 'src/libsvm/libsvm_template.cpp'
clang: error: no input files

I was able to download SciPy, NumPy, and nltk so not sure if there would be a dependency issue.

I'm not very familiar with Python packages and scikit-learn. Does anyone know what this error means / how to proceed?

Upvotes: 1

Views: 2180

Answers (3)

Ivan
Ivan

Reputation: 703

Don’t bother using setup.py files for manual installation unless you really have a specific reason for it. Just install Anaconda (a package manager) and use

conda install

In fact, it comes preinstalled with sklearn!

Upvotes: 0

Claude COULOMBE
Claude COULOMBE

Reputation: 3738

I've tried a lot of things but finally, including uninstall with the automated tools. So, I've uninstalled manually scikit-learn.

sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/sklearn
sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/scikit_learn-0.20.0-py3.6.egg-info

And re-install using pip

sudo pip3.6 install -U scikit-learn

Upvotes: 0

hoaphumanoid
hoaphumanoid

Reputation: 1007

You need to install libsvm. In linux is something like this:

sudo apt-get install libsvm-dev libsvm3 python-libsvm

You might have more uninstalled libraries. If they are python packages you can install them with pip. Please take a look at this guide.

Upvotes: 0

Related Questions