Search code examples
pythonscikit-learnanacondanuitka

Nuitka Error, implicit module 'sklearn.utils._unittest_backport' expected by 'sklearn.utils' not found


I am trying to compile my python script into single EXE. Nuitka can do this and has an acceptable license (Apache free license https://nuitka.net/pages/overview.html).

I was able to resolve 2 warnings by adding command line params below but I can't resolve the error below.

I've searched the web for a combination of Nuitka AND the error below but don't receive results specific enough to solve the issue.

I know it may be difficult to troubleshoot without the code, however let me know if there is a portion of the code I should extract to repro.

Do I need to somehow install "sklearn.utils._unittest_backport" to resolve this error?

I am running the following:

  • Nuitka v0.6.4
  • Python: 3.7.0
  • MSC v.1912 64 bit
  • OS: Windows
  • Arch: x86_64

The command line I am using is:

python -m nuitka --standalone --plugin-enable=sklearn --plugin-enable=numpy --nofollow-import-to=sklearn.utils._unittest_backport MyFile.py

The error I receive is:

Error, implicit module 'sklearn.utils._unittest_backport' expected by 'sklearn.utils' not found.

Any help you can provide would be appreciated.


Solution

  • I found a way to work around the error above. I ran

    pip install --user -U scikit-learn

    To check, I ran the following from the Python command line and it completed successfully:

    import sklearn.utils._unittest_backport

    I had scikit-learn previously installed, but it seems to have been missing the files I needed.

    FYI, _unittest_backport.py is here:

    C:\ProgramData\Anaconda3\Lib\site-packages\sklearn\utils