How to install/use PyAnsys in Mechanical CPython console?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 367
100 Answers 100 Comments 100 Likes First Anniversary
edited June 27 in Structures

How to install/use PyAnsys in Mechanical CPython console?

Best Answer

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 367
    100 Answers 100 Comments 100 Likes First Anniversary
    edited May 10 Answer ✓

    pyansys isn't installed by default in the Mechanical CPython scripting console. The user has to pip install it manually.

    Please use the following steps:

    1. Open command prompt as an administrator.
    2. Execute the command to download and install pyansys from https://pypi.org/project/pyansys/:

    "C:\Program Files\ANSYS Inc\v211\commonfiles\CPython\3_7\winx64\Release\python\python.exe" -m pip install pyansys

    1. Restart Mechanical and check if the installation is successful. enter image description here

    In case you get the following error: ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject

    It should be resolved by upgrading the numpy version shipped with the default Ansys WB 2021R1 installation. Execute the following command in the command prompt to upgrade numpy

    "C:\Program Files\ANSYS Inc\v211\commonfiles\CPython\3_7\winx64\Release\python\python.exe" -m pip install -U numpy

Answers

  • M
    M Member, Employee Posts: 169
    50 Answers 100 Comments 100 Likes First Anniversary

    @Ayush Kumar Can you update the link in the first line:


  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 367
    100 Answers 100 Comments 100 Likes First Anniversary

    @M Thanks for pointing out, setting up the environment variable is not needed anymore.

  • ChrisC
    ChrisC Member Posts: 7
    First Comment

    So one can open a CPython console in Mechanical? I though it was just IronPython?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 596
    100 Answers 250 Likes 100 Comments First Anniversary

    @ChrisC There is actually a beta option to use CPython in Mechanical. From the WB project page go to tools / options / appearance / and turn on beta options. Then also in tools / option go to the "Mechanical" section and activate the option to use CPython in Mechanical. As this is a beta option, there is no documentation, no support on using it, and no guarantee that it will work.