安装scikit-learn时出错

时间:2015-03-06 00:30:59

标签: python pip scikit-learn

尝试安装scikit-learn时,出现以下错误:

      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'

如何解决这个问题?

7 个答案:

答案 0 :(得分:18)

您是root用户吗?你有管理员权限吗?

你要做的一种方式:

$ sudo pip install scikit-learn

您需要输入密码然后它才能正常工作。

答案 1 :(得分:2)

从头开始安装scikit的一种直接方法是遵循以下步骤:

1)从https://pypi.python.org/pypi/pip/安装点数或使用

升级您的cmd
python -m pip install -U pip setuptools

2)运行

pip install wheel

3)下载numpy,scipy& scikit从http://www.lfd.uci.edu/~gohlke/pythonlibs/学习文件。 (numpy + MKL& scipy modules。检查你的python版本和32位或64位CPU。

4)在命令提示符下运行:

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

你准备好玩Scikit了解

5)在你的python shell中运行它:

import numpy, scipy, sklearn

注意:我在Windows上看到了几篇关于构建源的文章。您不必从源代码构建从Windows上的上述链接安装的二进制轮文件。

答案 2 :(得分:0)

sudo pip install scikit-learn 

这可以解决你的问题但是 我建议你为python项目安装virtualenv

1)安装virtualenv

[sudo] pip install virtualenv

2)转到项目目录并为python项目创建虚拟环境/隔离环境

virtualenv directory_name

3)激活虚拟环境

source directory_name/bin/activate

4)安装你想要的任何东西

pip install scikit-learn

答案 3 :(得分:0)

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

答案 4 :(得分:0)

如果您是管理员,

1)点击“开始”,然后输入“cmd”(不带引号)。

2)右键单击“cmd”图标并选择“以管理员身份运行”

3)在命令提示符下键入“pip install scikit-learn”。

答案 5 :(得分:0)

实际上,我最近在Windows10中遇到了针对python3的相同问题,然后尝试使用它对我有用。

 1.  python -m pip install -U pip setuptools

 2.  pip install scikit-learn

enter image description here

答案 6 :(得分:0)

运行两个命令后问题解决了

  1. 升级点

    $ / snap / pypy3 / 57 / bin / pypy3 -m pip install --upgrade pip

  2. 安装scikit学习

    $ sudo pip3 install -U scikit-learn