0

I am trying to run some code on python 2 and I keep getting this error No module named model_selection. I checked and for some reason the sklearn on my python2 is version 0.17 but when I try to update, it says that I already have an updated version but that is for python 3. How do I specifically update sklearn for python 2?

Error I get when running pip install -U scikit-learn: Requirement already up-to-date: scikit-learn in /home/ruven/anaconda3/lib/python3.6/site-packages (0.19.2)

Error I get when running python2.7 -m pip install -U scikit-learn:

Collecting scikit-learn
  Using cached https://files.pythonhosted.org/packages/bc/67/370aa248f54769a56216707ad7b9af19745e85a603fafa47bde353f327fb/scikit_learn-0.19.2-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: scikit-learn
  Found existing installation: scikit-learn 0.17
Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Ruven Guna
  • 414
  • 7
  • 25
  • Check out this answer. https://stackoverflow.com/questions/10919569/install-a-module-using-pip-for-specific-python-version – Steven Aug 14 '18 at 01:02
  • @Steven I just tried it but I still had an error. I have updated to question to include the error. Thank you. – Ruven Guna Aug 14 '18 at 01:10
  • 1
    Possible duplicate of [How do you uninstall a python package that was installed using distutils?](https://stackoverflow.com/questions/402359/how-do-you-uninstall-a-python-package-that-was-installed-using-distutils) – Joel Aug 14 '18 at 01:27
  • @dbliss I can't seem to delete the files in my /usr/lib/python2.7/dist-packages directory as I don't have the permission as this is my company's computer. – Ruven Guna Aug 14 '18 at 01:31
  • @dbliss I actually manage to solve it with easy_install. Thanks for your help though! – Ruven Guna Aug 14 '18 at 02:06

2 Answers2

3
sudo easy_install --upgrade scikit-learn
Red
  • 26,798
  • 7
  • 36
  • 58
2

Solved using the following command:

sudo easy_install --upgrade scikit-learn

Ruven Guna
  • 414
  • 7
  • 25