Application | PLAXIS 2D PLAXIS 3D |
Version | PLAXIS 2D CONNECT Edition V20 and later PLAXIS 3D CONNECT Edition V20 and later |
Date created | 13 October 2020 |
Date modified | 3 September 2024 |
When using the PLAXIS scripting environment it is common to use Python modules allowing for extending the functionality of a Python script. An example of a Python module is easygui, which offers an easy-to-use interface for simple GUI interaction with the user.
With the PLAXIS installer a PLAXIS-Python Distribution is provided and stored in a dedicated versioned location within the ProgramData folder (see release notes for PLAXIS 2D and 3D), including various Python modules.
This allows both PLAXIS 2D and PLAXIS 3D applications to access this shared distribution when using Python Scripting facilities, keeping all the modules up to date and fully compatible with PLAXIS.
This article will explain the available options in PLAXIS applications on how to install and use any Python modules required when scripting.
Since the release of PLAXIS CONNECT Edition V20 Update 3, a separation is made of the deliverable Python environment: one that can be used for user-created Python scripts and the editor, and one trimmed-down environment intended for all PLAXIS extensions implemented using Python language, e.g. the PLAXIS 2D to 3D converter and the structural Coupling tool, the parameter optimization tool for UDCAM-S constitutive model.
The PLAXIS-Python Distribution which can be used in automations includes various modules, such as easygui, matplotlib, numpy, pyperclip and it is placed in a dedicated versioned location within the ProgramData folder.
By default, this is stored in the folder: C:\ProgramData\
Depending on the installed version it can be different, for example:
To confirm which exact folder to use, go to PLAXIS Input, menu option Expert > Python > Configure Python Interpreter and see what is used as Default.
Since PLAXIS CONNECT Edition V20 Update 3 it is possible to configure PLAXIS to use a custom Python version, which is installed in the computer. To do so, the following steps are required:
Figure 1. Configure and use a custom Python distribution
Note: changing to a different Python interpreter means that all options for Python, such as Run Python Script/Tool, Interpreter, Editor will use the custom Python interpreter as configured.
Any errors encountered during the installation of the required components may be linked to the custom Python version.
It is possible to install various Python modules that are not already available in the PLAXIS-Python Distribution via the Command prompt window.
To do so, the following steps are required:
Figure 2. Example of installing pandas module using the PLAXIS Command prompt for PLAXIS CONNECT Edition V20 Update 3
Note that the installation of a Python module may require an updated version of another Python module. This may affect other modules that are available in the PLAXIS-Python Distribution, therefore, make sure to understand the changes made during the installation of any Python module.In the case that one of the various Python IDEs is used, such as PyCharm, Spyder, etc., the way of installing a Python module depends on each IDE.
Note that it is important in all cases to provide administrative rights to the application in order to allow for installing Python modules in the selected Python environment.