I'm attempting to use Python in concert with user subroutines to change material properties of a model between analysis steps. The update script Update_Properties.py
uses mpi4py
and is called from the UEXTERNALDB
subroutine like so:
STAT=SYSTEM("mpiexec -n 4 python /scratch/Update_Properties.py")
However, I keep getting this error:
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/gpfs/gpfs1/apps2/abaqus/2019/SimulationServices/V6R2019x/linux_a64/tools/SMApy/python2.7/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
This is on a RHEL HPC, using Python 3.6.1 and Abaqus 2019. The job is submitted via SLURM. Python 3.6.1 is used in instead of Abaqus Python because the latter lacks mpi4py
I've checked to ensure Python 3.6.1 is on the PATH
, and is the first Python present. I've also checked the PYTHONPATH
and PYTHONHOME
, both of which are not set on the system. I've noticed that when Abaqus runs, it adds a bunch of temporary entries to PYTHONPATH
though.
If Update_Properties.py
is directly submitted as a job, the script works just fine.
So far I have tried:
- Specifying the full path to Python 3.6.1 in the
SYSTEM()
call unset PYTHONPATH
immediately before the call toUpdate_Properties.py
unset PYTHONHOME
immediately before the call toUpdate_Properties.py
- Setting
PYTHONPATH
to the directories containing the Python 3.6.1 install immediately before the call toUpdate_Properties.py
- Calling
Update_Properties.py
using a bash script rather than directly
However, every time I get the aforementioned error.
I've looked at other question both on Stack Exchange and elsewhere, in particular:
External call to Python3.5 doesnot work from within Abaqus python
The answers given for these types of problems typically revolve around clearing or editing PYTHONPATH
and/or PYTHONHOME
which I've tried to no avail.