How to install an external iron python library (Ex.prettytable) to make it available in mechanical?

Options

The objective is to make some external library (Ex: Tabulate) available in mechanical scripting console.

To import this external C python library, I am running the following command in the command prompt.
"C:\Program Files\ANSYS Inc\v241\commonfiles\CPython\3_10\winx64\Release\python\python.exe" -m pip install tabulate

However, now, I am trying to do the same to import an external iron python library (Ex. prettytable).

Can you please tell me the procedure to do this?

Answers

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 117
    First Answer First Comment First Anniversary Ansys Employee
    admin
    Options

    @AKD-Scripting-Team to the rescue! If it is possible, one of them will know how!

  • M
    M Member, Employee Posts: 230
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Options

    @Shashidhar Reddy If you have the local path of your library, you should be able to add that path to the sys.path in the mechanical scripting editor.

    import sys ! already there even for ipy
    sys.path.append(path2library)

    import library

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 408
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Options

    @Shashidhar Reddy I don't think you can install external IronPython libraries as easily as for CPython. You can try downloading the source code and playing in the folder C:\Program Files\ANSYS Inc\v242\commonfiles\IronPython\Lib

    Not sure if that works but worth trying.