Troubleshooting#

This page covers common issues when launching or connecting to Mechanical.

Manually set the executable location#

If PyMechanical cannot find your installation, set the path manually:

On Windows

from ansys.mechanical.core import launch_mechanical

exec_loc = "C:/Program Files/ANSYS Inc/v261/aisol/bin/winx64/AnsysWBU.exe"
mechanical = launch_mechanical(exec_file=exec_loc)

On Linux

from ansys.mechanical.core import launch_mechanical

exec_loc = "/usr/ansys_inc/v261/aisol/.workbench"
mechanical = launch_mechanical(exec_file=exec_loc)

If Mechanical still fails to launch, pass verbose_mechanical=True to print debug output to the Python console.

Debug from the command line#

ansys-mechanical -g --port 10000

If this command doesn’t launch Mechanical, common causes include:

  • License server setup issues

  • Running behind a VPN

  • Missing dependencies

Debug with Visual Studio Code on Linux#

On Linux, the Python debugger must see the same environment that the mechanical-env scripts set when you run mechanical-env python. You can capture that environment once, store it in a file, and point Visual Studio Code at it.

  1. Install the Python extension for Visual Studio Code (provides the Python Debugger).

  2. From your project root, write the prepared environment to .vscode/.env. Use the same -r or -p options you use for normal runs:

    $ mechanical-env -r 261 env > .vscode/.env
    
  3. Create .vscode/launch.json with a launch configuration that loads that file:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python Debugger: Current File",
                "type": "debugpy",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "envFile": "${workspaceFolder}/.vscode/.env"
            }
        ]
    }
    
  4. Start Run and Debug, choose Python Debugger: Current File, and run your script.

Note

Regenerate .vscode/.env if you change the Ansys version, installation path, or mechanical-env options. Add .env to .gitignore to avoid committing local environment settings to version control.

Licensing issues#

PADT maintains an Ansys product section that includes posts about licensing.

If you are responsible for maintaining an Ansys license or have a personal installation of Ansys, you likely can access the Licensing section of the Ansys Help, where you can view or download the Ansys, Inc. Licensing Guide for comprehensive licensing information.

VPN issues#

Sometimes, Mechanical has issues starting when VPN software is running. For more information, see the Mechanical Users Guide in the Ansys Help.