PyMechanical
The Pythonic interface to Ansys Mechanical. Script, automate, and integrate structural simulation workflows from Python.
What it is
PyMechanical is part of the PyAnsys open-source ecosystem. It gives Python programs direct access to Ansys Mechanical, so engineers can drive structural simulations with scripts instead of clicks. I maintain the project, with ownership across testing, releases, CI/CD, and documentation.
Two ways to run Mechanical
- Embedding mode. Mechanical runs in-process through the
Appclass, so Python and Mechanical share one process. - Remote session mode. Mechanical runs as a separate process, and Python talks to it over gRPC. Start one with
launch_mechanical, or attach to a running instance withconnect_to_mechanical.
Getting started
Install the package with pip install ansys-mechanical-core. Optional extras add graphics, RPC, and MCP support. A licensed Ansys Mechanical installation (2024 R2 or later) is required.
At a glance
| Language | Python 3.12–3.14 |
|---|---|
| Supports | Ansys Mechanical 2024 R2 and later |
| Platforms | Windows and Linux |
| Transport | In-process embedding or gRPC |
| License | MIT |