Error Installing scikit-learn

2019-06-22 05:37发布

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?

6条回答
祖国的老花朵
2楼-- · 2019-06-22 05:55

If you are the admin,

1) Click on “Start” and type “cmd” (without the quotations).

2)Right Click on the “cmd” icon and select “Run as Administrator”

3)Type "pip install scikit-learn" in command prompt.

查看更多
欢心
3楼-- · 2019-06-22 05:58

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

enter image description here

查看更多
地球回转人心会变
4楼-- · 2019-06-22 05:59
sudo pip install scikit-learn 

This would solve your issue but I would recommend you to install virtualenv for python projects.

1) Install virtualenv

[sudo] pip install virtualenv

2) Go to your project directory and create virtual environment / isolated environment for python project

virtualenv directory_name

3) Activate virtual environment

source directory_name/bin/activate

4) Install whatever you want

pip install scikit-learn
查看更多
做个烂人
5楼-- · 2019-06-22 06:01

download the file whl in this site http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn I did download the 32bit files and use the pip install

查看更多
爷的心禁止访问
6楼-- · 2019-06-22 06:09

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.

查看更多
爷的心禁止访问
7楼-- · 2019-06-22 06:12

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.

查看更多
登录 后发表回答