Please try some code in this article:
https://optics.ansys.com/hc/en-us/articles/360041873053-Session-management-Python-API
Try one at the time and find which line does not work.
In addition, I personally suggest to use the software built-in Python version so it can work seamlessly.