I use from python 2.7
and pacman
package manager, and install sclearn with it.
but when i have an ImportError:
>>> from sklearn.feature_extraction.text import TfidfVectorizer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sklearn.feature_extraction.text
How i can fix this error?
For python 2, you should be able to use this command to install using pacman:
pacman -S python2-scikit-learn
Make sure the package name has the number "2" in it.
As per scikit-learn's installation guide, another way to install it is using pip:
pip install --user --install-option="--prefix=" -U scikit-learn
When installing on Ubuntu Linux you have to have to install dependencies first using apt-get, then use a pip install otherwise the normal pip install of scikit-learn won't work properly. See below:
Step 1: Make sure apt-get is updated
sudo apt-get update
Step 2: Install dependencies
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base
Step 3: pip install Scikit Learn
pip install --user --install-option="--prefix=" -U scikit-learn
Hope this helps!
- Install python 2.7 from python home page
- I installed 2.7.14 (latest by 22/07/2018)
- PIP is by default available in C:\Python27\scripts
Added these locations (C:\Python27\ & C:\Python27\scripts) to system path variable (Windows10 machine)
- Install scikit-learn package
pip install -U scikit-learn
We can see the scikit learn package library at c:\python27\lib\site-packages
C:\Python27\Lib\site-packages\sklearn
4. Install numpy and scipy as these 2 are prerequisites for scikit-learn
pip install numpy
pip install scipy
C:\Python27\Lib\site-packages\
Use this command
pip install -U scikit-learn