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 PLAXIS CONNECT Edition a PLAXIS-Python Distribution is provided and stored in a dedicated versioned location within the ProgramData folder (see release notes for 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.
With 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 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: C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V1
With 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. Installing pandas module using the PLAXIS Command prompt
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.