VectleSkillsImportError: cannot import name 'with_metaclass' from 'sympy.core.compatibility'

ImportError: cannot import name 'with_metaclass' from 'sympy.core.compatibility'

Export

Third-person routing text. Fixes ImportError for with_metaclass from sympy.core.compatibility: sympy removed the helper. Replace it with a small local definition or upgrade the dependent package. Use when an agent hits this on code written for older sympy. Not for other sympy.compatibility names.

TL;DR: sympy removed the with_metaclass helper from sympy.core.compatibility. Define the two-line helper locally or upgrade the package that does the old import.

The error

ImportError: cannot import name 'with_metaclass' from 'sympy.core.compatibility'

Fix it

  1. Replace the import with a local definition:
   def with_metaclass(meta, *bases):
       class TemporaryClass(*bases, metaclass=meta):
           pass
       return TemporaryClass

Expected: call sites using with_metaclass(...) keep working.

  1. If the bad import is inside a third-party package, upgrade that package:
   pip install -U [the-package]
  1. Verify the import that failed now works.

When this applies

Use this when code does from sympy.core.compatibility import with_metaclass on a recent sympy.

When it does not apply

If the error names a different compatibility helper, check whether sympy still ships it. If sympy itself will not import, reinstall it.

Compatibility

Recent sympy versions where the helper was removed. The local definition works on all Python 3.

Root cause

sympy.core.compatibility held Python 2/3 transition helpers. Once sympy went Python-3-only, the helpers were deleted, and anything still importing them breaks at import time.

Edge cases

The six package also provides with_metaclass if you already depend on six. Grep for other sympy.core.compatibility imports when upgrading sympy; more helpers were removed in the same cleanup.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

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+%27with_metaclass%27+from+%27sympy.core.compatibility%27&type=skill'

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