Install & Compatibility
Where this runs
tested against v12.0.2 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.278s · 232.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.5s · import 1.162s · 224MB
232MB installed
● package 232MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Basis
✓ from skfem import Basis
✗ from skfem.basis import Basis
Basis is a top-level export, not in a submodule.
Mesh
✓ from skfem import Mesh
✗ from skfem.mesh import Mesh
Mesh is exported from the top-level package.
BilinearForm
✓ from skfem import BilinearForm
✗ from skfem.assembly import BilinearForm
BilinearForm is a top-level export.
asm
✓ from skfem import asm
✗ from skfem.assembly import asm
asm is a top-level function.
np
✓ import numpy as np
scikit-fem relies heavily on numpy; always import numpy.
Assemble a simple 2D Poisson problem: -Δu = 1 on unit square with zero Dirichlet BCs (not applied).
import numpy as np
from skfem import Mesh, Basis, BilinearForm, LinearForm, asm
from skfem.helpers import dot, grad
# Create a simple unit square mesh
mesh = Mesh().refined(2)
# Define basis for linear elements
basis = Basis(mesh, ElementTriP1())
# Define bilinear form for Laplacian
@BilinearForm
def laplace(u, v, w):
return dot(grad(u), grad(v))
# Assemble stiffness matrix
A = asm(laplace, basis)
# Define linear form for rhs
@LinearForm
def rhs(v, w):
return 1.0 * v
# Assemble rhs vector
b = asm(rhs, basis)
# Solve (requires scipy or similar)
# x = np.linalg.solve(A, b)
print(A.shape)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'skfem'
scikit-fem not installed or environment not activated.
fixRun 'pip install scikit-fem' in your terminal.
AttributeError: module 'skfem' has no attribute 'ElementTriP1'
ElementTriP1 is in skfem.element module but often imported directly. The error may occur if using old import path.
fixUse 'from skfem import ElementTriP1' or 'from skfem.element import ElementTriP1'.
TypeError: 'BilinearForm' object is not callable
Incorrect usage of BilinearForm decorator; likely calling the decorator incorrectly.
fixUse '@BilinearForm' on a function that takes (u, v, w) and returns a scalar expression. Then pass to asm.
Upgrade
Version history
12.0.2latest on PyPI · released Jun 5, 2026
Audit
Dependencies
No dependency data recorded yet.