Reputation: 1063
Note upfront: I tried following suggestions in other threads, but so far, haven't found anything that helps (1, 2)
I received a pandas file that I would like to run on my machine. In the beginning, the code references the sklearn package.
import re
from sklearn.decomposition import FactorAnalysis
from sklearn import svm
I do, however, get the following error when running this cell:
ModuleNotFoundError: No module named 'sklearn.decomposition'
I do have the scikit_learn-0.19.0-py3.6.egg-info and sklearn packages in my Python directory, so I'm not sure why it doesn't work. I tried reinstalling it, but both...
conda install scikit-learn
...and...
pip install scikit-learn
...don't work. The former crashes my Python (pop-up window telling my it has crashed), the latter produces a bunch of error messages:
>pip install scikit-learn
Requirement already satisfied: scikit-learn in c:\programdata\...\lib\site-packages
Exception:
Traceback (most recent call last):
File "C:\ProgramData\...\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\ProgramData\...\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\ProgramData\...\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\ProgramData\...\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\ProgramData\...\lib\site-packages\pip\req\req_set.py", line 666, in _prepare_file
check_dist_requires_python(dist)
File "C:\ProgramData\...\lib\site-packages\pip\utils\packaging.py", line 48, in check_dist_requires_python
feed_parser.feed(metadata)
File "C:\ProgramData\...\lib\email\feedparser.py", line 175, in feed
self._input.push(data)
File "C:\ProgramData\...\lib\email\feedparser.py", line 103, in push
self._partial.write(data)
TypeError: string argument expected, got 'NoneType'
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Any idea how I can get it to work? Thanks
Upvotes: 2
Views: 10306
Reputation: 919
Actually, I was facing the same problem in windows10 recently for python3 then I try this it worked for me.
1. python -m pip install -U pip setuptools
2. pip install scikit-learn
Upvotes: 0
Reputation: 725
If you are on linux...
1). download anaconda https://www.anaconda.com/download/#download
2). go to where the file is downloaded and type bash Anaconda-latest-Linux-x86_64.sh
The new anaconda already comes with scikit-learn installed.
If you need an older version of python like I did you can install that version by typing
conda install python=3.6
Upvotes: 0
Reputation: 1063
Solved it.
Code works now, thanks all who contributed.
Upvotes: 1
Reputation: 588
Try running that last command to upgrade pip first?
pip install --upgrade pip
And then install scikitlearn afterwards. And possibly try this depending on what version of python you're using in your environment:
pip3 install scikit-learn
Upvotes: 3