Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Installing scikit-learn

When trying to install scikit-learn, I get the following error:

      Exception:
      Traceback (most recent call last):
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 232, in main
          status = self.run(options, args)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/commands/install.py", line 347, in run
          root=options.root_path,
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_set.py", line 543, in install
          requirement.uninstall(auto_confirm=True)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_install.py", line 667, in uninstall
          paths_to_remove.remove(auto_confirm)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
          renames(path, new_path)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/utils/__init__.py", line 316, in renames
          shutil.move(old, new)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move
          rmtree(src)
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
          onerror(os.remove, fullname, sys.exc_info())
        File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
          os.remove(fullname)
      OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/numpy-1.8.0-py2.7.egg-info/dependency_links.txt'

How can this be resolved?

like image 304
Adam_G Avatar asked Mar 06 '15 00:03

Adam_G


People also ask

How do I fix sklearn error?

The Python "ModuleNotFoundError: No module named 'sklearn'" occurs when we forget to install the scikit-learn module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install scikit-learn command.

Can we install scikit-learn with pip?

Installing the latest release Using such an isolated environment makes it possible to install a specific version of scikit-learn with pip or conda and its dependencies independently of any previously installed Python packages.

How do I install scikit-learn on Windows?

Download the source package from http://pypi.python.org/pypi/scikit-learn/ , unpack the sources and cd into the source directory. or alternatively (also from within the scikit-learn source folder): pip install . Packages installed with the python setup.py install command cannot be uninstalled nor upgraded by pip later.

How do I add Scikit to Python?

pip install scikit-learn Instead, consider installing Python libraries from source code. The simplest way to build scikit-learn from source is to use the ActiveState Platform to automatically build and package it for Windows, Mac or Linux.


2 Answers

Are you the root user? Do you have admin privileges?

One way you be to do:

$ sudo pip install scikit-learn

You will need to type your password and then it should work.

like image 137
Alexander Huszagh Avatar answered Sep 22 '22 10:09

Alexander Huszagh


One straight way to install scikit learn from scratch is following the below steps:

1) install pip from https://pypi.python.org/pypi/pip/ or upgrade in your cmd using

python -m pip install -U pip setuptools

2) run

pip install wheel

3) download the numpy, scipy & scikit learn files from http://www.lfd.uci.edu/~gohlke/pythonlibs/. (numpy+MKL & scipy modules. Check for your python version and 32 bit or 64 bit CPU.

4) run these in your command prompt:

pip install numpy-1.12.1+mkl-cp36-cp36m-win_amd64.whl

pip install scipy-0.19.0-cp36-cp36m-win_amd64.whl

pip install scikit_learn-0.18.1-cp36-cp36m-win_amd64.whl

You are ready to play with Scikit learn

5) run this in your python shell:

import numpy, scipy, sklearn

Note: I saw several articles on building from source on windows. You don't have to build from source for binary wheel files that you installed from the above link on your windows.

like image 26
Aakash Saxena Avatar answered Sep 23 '22 10:09

Aakash Saxena