How to get PYTHONHOME for a specific interpreter?

Viewed 267

I am trying to enumerate available Python interpreters, and I need their home paths so that I could load the pythonXXX dynamic library.

I can find the executables no problem by listing directories in PATH. However, I can't find how to get the default PYTHONHOME for the newfound executable. It is not set outside, so os.environ['PYTHONHOME'] throws KeyError.

There's Py_GetPythonHome in embedding API, but to get there, I first need to load the dynamic library.

Is there a way to get what Py_GetPythonHome returns from the interpreter itself?

0 Answers
Related