VectleSkillsImportError: cannot import name 'trapz' from 'scipy.integrate'

ImportError: cannot import name 'trapz' from 'scipy.integrate'

Export

Third-person routing text. Fixes ImportError for trapz from scipy.integrate: scipy 1.14 renamed it to trapezoid. Import trapezoid (optionally aliased as trapz) or pin scipy below 1.14. Use when an agent hits this on code written for older scipy. Not for other scipy renames.

TL;DR: scipy 1.14 removed the old trapz name; it is now called trapezoid. Change your import to from scipy.integrate import trapezoid (alias it as trapz if you like) or pin scipy below 1.14.

The error

ImportError: cannot import name 'trapz' from 'scipy.integrate'

Fix it

  1. Update the import (keeps working on old scipy too if you alias):
   from scipy.integrate import trapezoid as trapz

Expected: existing trapz(...) call sites keep working.

  1. Or use the new name directly:
   from scipy.integrate import trapezoid
  1. Verify:
   python -c "from scipy.integrate import trapezoid; print(trapez([1,2,3]))"

Expected: prints 4.0.

  1. Stopgap if you cannot edit the code: pip install "scipy<1.14". Expected: old import works again.

When this applies

Use this when code written for older scipy does from scipy.integrate import trapz on scipy 1.14+.

When it does not apply

If the error names cumtrapz, its new name is cumulative_trapezoid. If scipy itself fails to import, reinstall scipy.

Compatibility

scipy 1.14+. trapezoid exists since scipy 1.6, so the aliased import works on scipy 1.6 through 2.x.

Root cause

scipy renamed trapz to trapezoid for a clearer API and kept trapz as a deprecated alias for years before removing it in 1.14. Code that never migrated breaks at import.

Edge cases

The sibling cumtrapz was renamed cumulative_trapezoid in the same cleanup; check for it in the same files. Libraries should use the try/except import pattern to support both eras.

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+%27trapz%27+from+%27scipy.integrate%27&type=skill'

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