Corrected sys.executable

530
3
10-27-2021 01:00 PM
Status: Open
Labels (1)
Thomas-Zuberbuehler
New Contributor III

sys.executable should work as specified in the Python specification.

A string giving the absolute path of the executable binary for the Python interpreter, on systems where this makes sense. If Python is unable to retrieve the real path to its executable, sys.executable will be an empty string or None.

Source: https://docs.python.org/3/library/sys.html#sys.executable (emphasis are mine)

sys.executable should be either None or an empty string or C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe (or the path of the python.exe of the currently used Python environment).

As of today, sys.executable is equals C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe when using the ArcGIS Pro built-in Python console or the built-in Notebook feature.

ArcGISPro.exe is obviously not a Python interpreter. 

3 Comments
DanPatterson

sys.prefix


'C:\\your_install_folder\\bin\\Python\\envs\\arcgispro-py3'

"C:\your_install_folder\bin\Python\envs\arcgispro-py3\python.exe"

Luke_Pinner

@Thomas-Zuberbuehler wrote:

ArcGISPro.exe is obviously not a Python interpreter. 


Don't be so sure...

https://docs.python.org/3/extending/embedding.html

Thomas-Zuberbuehler

I guess it all comes down how Esri interprets this paragraph:

Embedding Python is similar to extending it, but not quite. The difference is that when you extend Python, the main program of the application is still the Python interpreter, while if you embed Python, the main program may have nothing to do with Python — instead, some parts of the application occasionally call the Python interpreter to run some Python code.

Source: https://docs.python.org/3/extending/embedding.html (emphasis are mine)