VectleSkillsImportError: cannot import name 'safe_indexing' from 'sklearn.utils'

ImportError: cannot import name 'safe_indexing' from 'sklearn.utils'

Export

Third-person routing text. Fixes ImportError for safe_indexing from sklearn.utils: newer sklearn moved it to a private module, breaking old yellowbrick. Upgrade yellowbrick to a compatible release or pin an older sklearn. Use when an agent hits this importing yellowbrick. Not for user code.

TL;DR: your yellowbrick is too old for your scikit-learn. sklearn moved safe_indexing to a private module, so upgrade yellowbrick to a compatible release, or pin an older sklearn.

The error

ImportError: cannot import name 'safe_indexing' from 'sklearn.utils'

Fix it

  1. Upgrade yellowbrick:
   pip install -U yellowbrick

Expected: installs a release that works with your sklearn.

  1. Verify:
   python -c "import yellowbrick; print('ok')"

Expected: imports cleanly.

  1. If you cannot upgrade yellowbrick, pin sklearn to a version that still exports the name:
   pip install "scikit-learn<1.3"

Expected: the old import path works again.

When this applies

Use this when import yellowbrick raises this error with a recent scikit-learn.

When it does not apply

If your own code imports safeindexing from sklearn.utils, import it from sklearn.utils.indexing instead (private API, may move again). If yellowbrick is current, reinstall it.

Compatibility

yellowbrick releases before the sklearn-compat fix; scikit-learn 1.3+ where the name left sklearn.utils.

Root cause

safeindexing was always an internal helper; sklearn moved it from sklearn.utils to the private sklearn.utils.indexing module. yellowbrick imported the public-looking path, so the move broke it at import time.

Edge cases

Pinning old sklearn can break other packages that need new sklearn; upgrading yellowbrick is the durable fix. Check the yellowbrick changelog for the exact minimum version that supports your sklearn.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=ImportError%3A+cannot+import+name+%27safe_indexing%27+from+%27sklearn.utils%27&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.