scikit-learn: Importing scikit-learn==0.24.0 fails on macOS 10.13: "Symbol not found: ____chkstk_darwin"

Describe the bug

Importing scikit-learn==0.24 fails on macOS 10.13.

I believe this is similar to https://github.com/nodegui/nodegui/issues/391, i.e. the prebuilt libomp binary (from 10.15) isn’t compatible with macOS 10.13.

We’re also tracking this issue on the project where we encountered it: https://github.com/neuropoly/spinalcordtoolbox/issues/3121.

Steps/Code to Reproduce

  1. Install scikit-learn==0.24.0 on macOS 10.13 (for us, it appeared as a successful install)
  2. Import scikit-learn (for us, an error was thrown)

Expected Results

No error is thrown.

Actual Results

dlopen(/Users/travis/build/neuropoly/spinalcordtoolbox/python/envs/venv_sct/lib/python3.6/site-packages/sklearn/__check_build/_check_build.cpython-36m-darwin.so, 2): Symbol not found: ____chkstk_darwin
  Referenced from: /Users/travis/build/neuropoly/spinalcordtoolbox/python/envs/venv_sct/lib/python3.6/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/travis/build/neuropoly/spinalcordtoolbox/python/envs/venv_sct/lib/python3.6/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib
___________________________________________________________________________
Contents of /Users/travis/build/neuropoly/spinalcordtoolbox/python/envs/venv_sct/lib/python3.6/site-packages/sklearn/__check_build:
__init__.py               __pycache__               _check_build.cpython-36m-darwin.so
setup.py
___________________________________________________________________________
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.

Versions

  • Python: python-3.6.12
  • Numpy: numpy-1.19.4
  • Scipy: scipy-1.5.4
  • Scikit-learn: scikit-learn-0.24.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 16 (13 by maintainers)

Most upvoted comments

Thank you very much for the confirmation. We will include this fix in a 0.24.1 release (soon-ish).

This was fixed with the 0.24.1 release a few days ago.

For anyone who stumbles on this in the meantime (looks like the awesome scikit-learn team is going to have a fix soon, regardless), using pip install -U scikit-learn==0.23 solves this problem.

I created a repo call sklearn_osx_travis_test just to test the install of the scikit-learn wheels on osx 10.13. When we build the wheels for scikit-learn 0.24.1 to fix this issue, we can submit a PR to sklearn_osx_travis_test to make sure that this issue is fixed before uploading the wheels to pypi.

Note that 0.23.2 has some bugfixes over 0.23.0 and was built using the previous CI infrastructure, so it has good chance to also work while waiting for 0.24.0.post1 or 0.24.1 with a proper fix.

Could you please to install the macos wheels for your Python version from this archive to let us know if that fixes the problem for you?

https://github.com/scikit-learn/scikit-learn/suites/1717904983/artifacts/32468159

Awkwardly, curl/wget don’t seem to like that link. But, I did test it in this CI build.

I’m not getting the error I was getting previously, so the fix seems like it’s working. 🙂

[Update] scikit-learn >= 0.24.1 solved this issue.

Error: libomp.dylib (which was built for Mac OS X 10.15)

ImportError: dlopen(~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/_check_build.cpython-38-darwin.so, 2): Symbol not found: ____chkstk_darwin
  Referenced from: ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib

Versions

  • macOS: High Sierra 10.13.6
  • Python: python@3.8 3.8.6_2
  • scikit-learn: 0.24.0

Interim solution

Fallback to 0.23.0 previous version of scikit-learn solved the issue in requirements.txt:

scikit-learn == 0.23.0

Full Log

Traceback (most recent call last):
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build  # noqa
ImportError: dlopen(~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/_check_build.cpython-38-darwin.so, 2): Symbol not found: ____chkstk_darwin
  Referenced from: ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib
 in ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__init__.py", line 81, in <module>
    from . import __check_build  # noqa: F401
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
  File "~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/__init__.py", line 31, in raise_build_error
    raise ImportError("""%s
ImportError: dlopen(~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/_check_build.cpython-38-darwin.so, 2): Symbol not found: ____chkstk_darwin
  Referenced from: ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib
 in ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib
___________________________________________________________________________
Contents of ~/.local/share/virtualenvs/env-SYAMQg7D/lib/python3.8/site-packages/sklearn/__check_build:
__init__.py               __pycache__               _check_build.cpython-38-darwin.so
setup.py
___________________________________________________________________________
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.

Although I am not sure how libomp itself is installed on this machine.

Possibly relevant:

https://github.com/scikit-learn/scikit-learn/blob/2f09bbb7eb2fffdffcca3667b8fc38990d3b0893/build_tools/github/build_wheels.sh#L6-L15

Also possibly relevant is:

https://github.com/nodegui/nodegui/issues/391#issuecomment-582788859

Need to add CMAKE_OSX_DEPLOYMENT_TARGET to an older version of mac than the latest to make the binary compatible.

Thanks for looking into this @ogrisel . On apprecie l’aide, même que c’est déjà les vacances dans le plupart des lieux.