pip. However, you can still import and use Python modules that are not included with the ACP installation (for example, matplotlib). To do this, create a virtual Python environment (VENV) and add it to the ACP Python path.
Create a virtual environment
Before creating the virtual environment, make sure you use the same Python version that ACP uses. To check the version, runsys.version in ACP’s Python shell.
There are several ways to create a new VENV:
-
Using the Ansys-delivered Python:
Navigate to the delivered Ansys Python that is in the
subfolder of
<WB root dir>\commonfiles\CPythonand call the venv module.This creates a new environment inC:\my_ansys_python_env. -
Using a standard Python installation:
After installing Python, run:
This creates a new environment in
C:\my_new_python_env. - Using another Python distribution: Tools such as Anaconda also enable you to create virtual environments.
Install a module in the virtual environment
Activate the virtual environment before installing additional modules. For example, using the Windows Command Prompt:Use virtual-environment modules inside ACP
To make VENV-installed modules available in ACP, append the VENV paths tosys.path inside ACP.
-
In the virtual environment, run:
Copy the returned list of paths.
-
In ACP’s Python shell, extend the ACP path:
<installation dir>\commonfiles\CPython. This Python build may differ from an official Python distribution (different compiler, different binary modules, or different bundled libraries). As a result, packages installed in your VENV may not be fully compatible with ACP’s Python, even if they share the same version number.
Alternatives to extending ACP’s Python
For data exchange (for example, dictionaries, NumPy arrays, and other objects), you can write data to disk and load it in another environment. One option is Python’s built‑in pickle module. Example: Saving data with picklenumpy.save, numpy.savez, and numpy.load.