AnsweredAssumed Answered

Get Pro install folder location from Python

Question asked by curtvprice Champion on Jun 28, 2017
Latest reply on Jun 29, 2017 by curtvprice

Hi all, I have a puzzle for you today. I am trying to get the ArcGIS Pro install folder from Python.  I am open to suggestions on how to accomplish this task, but the following approach should work (and works for me with Desktop, although I usually use os.environ["AGSDESKTOPJAVA"] instead).

  • I don't want to use arcpy.GetInstallInfo() because I want to find out where the install is before I take the time to import arcpy.
  • We install in a non-standard location to avoid spaces in the path.  


Here is my attempt:


Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _winreg
>>> with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
...                      r"SOFTWARE\ESRI\ArcGISPro") as key:
...     pro_path = _winreg.QueryValueEx(key, "InstallDir")[0]
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
WindowsError: [Error 2] The system cannot find the file specified


And yet, I can see this key with reg query fine:


D:\Users\jwpowell>reg query HKLM\SOFTWARE\ESRI\ArcGISPro /v InstallDir

InstallDir REG_SZ C:\ArcGIS\Pro\


See, it works in Desktop. 

>>> with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
...                      r"SOFTWARE\WOW6432Node\ESRI\ArcGIS") as key:
...     dt_path = _winreg.QueryValueEx(key, "InstallDir")[0]
>>> dt_path
u'C:\\Program Files (x86)\\Common Files\\ArcGIS\\'

Is this a x64/x32 thing?