2017-08-02 116 views
0

我分叉了scikit-learn repository,添加了一个我需要的文件并下载了存储库。我不知道如何使用这个custom library。我cd'ed scikit学习主文件夹,并试图使用它,但它会引发错误。所以在阅读我使用python3 setup.py install安装它的错误之后。有两个setup.py文件。一个在scikit-learn-master文件夹和sklearn文件夹中,因此我在这两个位置都运行了python3 setup.py install。他们抛出一些警告,但没有错误。我打开蟒蛇终端在scikit-learn-master文件夹,并使用import sklearn返回如下 -安装自定义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

看起来该模块没有被正确构建。所以它显示check_build的importError。

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

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获取常见问题解答。

+0

我使用'numpy.version.version'和'scipy.version.version'检查了scipy和numpy的版本。它为python2和python3提供了'1.13.1'和'0.19.1'。我使用Python 2.7.10(...'和python'3.6.0(...'。我想还有其他东西我在这里丢失。 –

+1

@ClockSlave嗨,所以我安装了它 - 当我运行'在python shell中import sklearn没有错误,我在Fedora上,我用的步骤是'sudo dnf install python-numpy','dnf install python-scipy'和'dnf install python-scikit-learn'。建议删除分叉的回购和安装通过命令行,如果你在Linux上。希望它有帮助。 – nj2237

+0

感谢您花时间检查这个。我可以使用安装sklearn使用点或家庭酿造,但我试图使用分叉回购是因为我已经添加了一个文件分叉repo。我想检查它是否按预期运行。事实上,我已经安装了原始sklearn软件包。它的分叉回购,我需要安装并检查我的代码是正确的 –