2017-08-02 138 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軟件包。它的分叉回購,我需要安裝並檢查我的代碼是正確的 –