0

I forked the scikit-learn repository, added a file that I need and downloaded the repository. I am not sure how to use this custom library. I cd'ed to the scikit-learn-master folder and tried to use it but it throws errors. So after reading the errors I installed it using python3 setup.py install. There were two setup.py files. One in the scikit-learn-master folder and sklearn folder so I ran python3 setup.py install at both these locations. They threw some warnings but no errors. I opened the python terminal in the scikit-learn-master folder and used import sklearn which returns the following -

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.

I am not sure how to proceed. Is there anything I am missing?

Clock Slave
  • 7,627
  • 15
  • 68
  • 109

1 Answers1

1

It appears the module has not been built correctly. And so it shows importError for check_build.

Before installing the module using pip, make sure you have installed all of the dependencies. On the README file, the mentioned packages are:

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

If you are not planning on contributing to the project, but only using it, it is recommended that you download from https://pypi.python.org/pypi/scikit-learn instead of forking it.

View detailed instructions on how to install here.

After installing and building this way, if you still have issues, you can refer http://scikit-learn.org/stable/faq.html for FAQs.

nj2237
  • 1,220
  • 3
  • 21
  • 25
  • I checked the versions of scipy and numpy using `numpy.version.version` and `scipy.version.version`. It gives `1.13.1` and `0.19.1` for python2 and python3 both. I am using python `2.7.10 (...` and python `3.6.0 (...`. I guess there's something else I am missing here. – Clock Slave Aug 02 '17 at 10:21
  • 1
    @ClockSlave Hi, so I installed it - and when I ran `import sklearn` on python shell there were no errors. I'm on Fedora and the steps I used were `sudo dnf install python-numpy`, `dnf install python-scipy` and `dnf install python-scikit-learn`. I suggest removing the forked repo and installing via command line if you are on Linux. Hope it helps. – nj2237 Aug 02 '17 at 10:55
  • Thanks for taking the time to check this. I can use install sklearn using pip or home brew, but the reason I am trying to use the forked repo is because I have added a file to that forked repo. I want to check if it functions as intended. Matter of fact, I have the original sklearn package installed. Its the forked repo that I need to install and check if my codes are correct. – Clock Slave Aug 02 '17 at 10:59
  • 1
    @ClockSlave Oh alright then - okay, why don't you try downloading the forked repo first, see if it works and then add your file and check? Because, it maybe your file that you need to modify to get it to work – nj2237 Aug 02 '17 at 11:19
  • Okay so I downloaded the original sklearn repo and tried installing it but have been running into errors ever since. This is what I am getting https://pastebin.com/6TY1eyK6 . Do you know what it means? – Clock Slave Aug 02 '17 at 12:28
  • 1
    So after all the trying and failing. I finally decided to go to the site package folder, looked up for sklearn and pasted the file there and made a change to the `__init__.py` file. It works now. I know its not advisable but it was my last resort. Thanks for all your help. Cheers. – Clock Slave Aug 02 '17 at 12:51