Registry / data / symengine

symengine

JSON →
library0.14.1pypypi✓ verified 85d ago

SymEngine.py is a Python library providing high-performance wrappers to the SymEngine C++ symbolic manipulation library. It aims to offer a fast and efficient alternative for symbolic mathematics in Python, often used as a backend for SymPy or independently. The library is actively maintained, with frequent releases that typically follow updates to the core C++ SymEngine library.

pip install symengine
INSTALL
IMPORT
SIG · SYMENGINE
S
symengine
datapythonv0.14.1
Install
3.1s avg
Import
17ms
Disk
143MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.14.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.1s · import 0.017s · 145MB
143MB installed
● package 143MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

symengine
import symengine
Symbol
from symengine import Symbol
sin
from symengine import sin

This quickstart demonstrates how to define symbolic variables, create an expression, compute a derivative, and perform substitutions using SymEngine.

import symengine from symengine import Symbol, sin x = Symbol('x') y = Symbol('y') expr = x + y**2 print(f"Original expression: {expr}") derivative = expr.diff(y) print(f"Derivative with respect to y: {derivative}") # Substitution substituted_expr = expr.subs(x, sin(y)) print(f"Expression after substituting x=sin(y): {substituted_expr}")
Debug
Known issues
breakingPython version support changes across major versions. For instance, v0.9.0 dropped Python 3.6 support, v0.11.0 required Python >=3.8, and v0.14.1 dropped Python 3.8 support. Always check `requires_python`.
fix
Ensure your Python environment meets the `requires_python` specification for the installed SymEngine version. Upgrade or downgrade Python as necessary.
affects: 0.9.0, 0.11.0, 0.14.1
breakingThe default backend for `lambdify` changed to LLVM when available in v0.10.0. This might alter performance or require LLVM dependencies if relying on `lambdify`'s default behavior.
fix
If specific `lambdify` behavior is required, explicitly specify the `backend` argument. Ensure LLVM is correctly configured if you intend to use the LLVM backend for performance.
affects: >=0.10.0
breakingConversion of `ImmutableMatrix` to SymPy/Sage results in immutable matrices since v0.10.0. Also, `Mul` and `Add` operations of immutable and dense matrices result in immutable matrices since v0.9.0.
fix
Adjust code that expects mutable matrices after conversion or matrix operations. If mutability is critical, explicitly convert to a mutable matrix type after the operation.
affects: >=0.9.0, >=0.10.0
gotchaBuilding `symengine` from source (e.g., via `pip install .` for development) requires `cmake` and often depends on a specific commit/tag of the core C++ SymEngine library. Mismatched versions can lead to build failures.
fix
For ease of installation, use pre-built wheels via `pip install symengine` or the `conda` package. If building from source, ensure `cmake` is installed and the C++ SymEngine library is at a compatible version as specified in the `symengine.py` repository.
affects: All versions (when building from source)
gotchaInteroperability with `SymPy` can introduce performance overhead if SymEngine objects are frequently converted to SymPy objects and vice versa, as this might involve traversing expression trees and creating new objects.
fix
Minimize explicit conversions between SymEngine and SymPy objects. If performance is critical, try to keep calculations within the SymEngine domain as much as possible. Consider using `symengine` as a backend for `sympy` where supported.
affects: All versions (when mixing SymEngine and SymPy)
Errors
Common errors & fixes
error: Microsoft Visual C++ 14.0 or greater is required.
Symengine is a C++ library with Python bindings, requiring a C++ compiler and associated build tools to be present and configured on your system for `pip install` to compile the extension modules.
fix
Install the appropriate C++ build tools for your operating system (e.g., 'Build Tools for Visual Studio' on Windows, `build-essential` package on Debian/Ubuntu, Xcode Command Line Tools on macOS).
ModuleNotFoundError: No module named 'symengine'
The `symengine` library is not installed in the current Python environment or the Python interpreter cannot find it.
fix
Install the library using `pip install symengine` in your active Python environment.
fatal error: boost/config.hpp: No such file or directory
Symengine requires Boost C++ development headers to be installed on the system for successful compilation, and these headers were not found during the `pip install` process.
fix
Install the Boost development libraries for your operating system (e.g., `libboost-dev` on Debian/Ubuntu, `boost` via Homebrew on macOS, or manually download/build on Windows and ensure relevant environment variables are set).
TypeError: Argument 'arg' has incorrect type (expected <class 'symengine.lib.symengine.basic.Basic'>, got <class 'sympy.core.symbol.Symbol'>)
Symengine functions and operations expect Symengine-specific objects (e.g., `symengine.Symbol`, `symengine.Expr`), but a SymPy object was passed instead.
fix
Convert SymPy objects to Symengine objects using `symengine.convert` or define variables using `symengine.Symbol` directly when working with Symengine. Example: `symengine.sin(symengine.convert(x_sympy))` or `x_symengine = symengine.Symbol('x'); symengine.sin(x_symengine)`.
Upgrade
Version history
0.14.1latest on PyPI · released Apr 21, 2025
Audit
Dependencies
symengine (C++ library)requiredCore symbolic manipulation engine, wrapped by this Python library.
cythonoptionalUsed for generating Python bindings from C++ code.
sympyoptionalOptional dependency for interoperability and extended functionality.
numpyoptionalOptional dependency, especially for numerical evaluation (lambdify).
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
symengine — pip install symengine · libregistry