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

Shashidhar Reddy
Shashidhar Reddy Member, Employee Posts: 3
First Comment
✭✭✭

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: 183
    5 Answers 100 Comments Photogenic Name Dropper
    admin

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

  • M
    M Member, Employee Posts: 235
    100 Comments Photogenic 5 Likes Name Dropper
    ✭✭✭✭

    @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: 444
    250 Likes Solution Developer Community of Practice Member Ansys Employee First Anniversary
    ✭✭✭✭

    @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.