安装自定义sklearn

时间:2017-08-02 09:43:25

标签: python git installation scikit-learn

我分叉scikit-learn repository,添加了我需要的文件并下载了存储库。我不确定如何使用此custom library。我cd到scikit-learn-master文件夹并尝试使用它但它会抛出错误。因此,在阅读错误后,我使用python3 setup.py install安装了它。有两个setup.py个文件。一个位于scikit-learn-master文件夹和sklearn文件夹中,因此我在这两个位置都运行了python3 setup.py install。他们提出了一些警告但没有错误。我在scikit-learn-master文件夹中打开了python终端并使用import sklearn返回以下内容 -

Traceback (most recent call last):
  File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build  # noqa
ModuleNotFoundError: No module named 'sklearn.__check_build._check_build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__init__.py", line 128, in <module>
    from . import __check_build
  File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
  File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 41, in raise_build_error
    %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named 'sklearn.__check_build._check_build'
___________________________________________________________________________
Contents of /Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build:
__init__.py               __pycache__               _check_build.c
_check_build.pyx          setup.py                  setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.

If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.

我不知道该怎么办。有什么我想念的吗?

1 个答案:

答案 0 :(得分:1)

模块似乎未正确构建。所以它显示了check_build的importError。

在使用pip安装模块之前,请确保已安装所有依赖项。在README文件中,提到的包是:

Python (>= 2.7 or >= 3.3)
NumPy (>= 1.8.2)
SciPy (>= 0.13.3)
For running the examples Matplotlib >= 1.1.1 is required.

如果您不打算为该项目做出贡献,但仅使用它,建议您从https://pypi.python.org/pypi/scikit-learn下载而不是分支。

查看有关如何安装here的详细说明。

以这种方式安装和构建后,如果仍有问题,可以参考http://scikit-learn.org/stable/faq.html获取常见问题解答。