JamesRamm / archook

Searches the system for arcgis and makes arcpy available to python (regardless of pythonpath/system path/registry settings)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_arcpy() got an unexpected keyword argument 'pro'

PeterBetlem opened this issue · comments

commented

The above plus "ImportError: Could not locate the ArcGIS directory on this machine" if disabling the pro parameter are found on a fresh conda python=3.6 with newly installed ArcGIS Pro 2.x (tried 2.1, 2.5, 2.5.1):

import archook #The module which locates arcgis
archook.get_arcpy(pro = True)
import arcpy
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-31d7c887ec7a> in <module>
      5 import Archook #The module which locates arcgis
----> 6 archook.get_arcpy(pro = True) # removal of pro keyword leads to second error.
      7 import arcpy

TypeError: get_arcpy() got an unexpected keyword argument 'pro'

The issue is fixed by downloading a fresh archook copy from the github repo, and uncommenting/hardcoding the path:

def get_pro_paths():
    """Return 2 lists, for adding to Windows PATH and python sys.path"""
    P = locate_arcgis(pro=True)
    C = locate_pro_conda()
    P = r"C:\Program Files\ArcGIS\Pro"
    C = r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3"
import sys
import os

sys.path.insert(1,os.environ["HOMEDRIVE"]+os.environ["HOMEPATH"]+'/Documents/GitHub/arcgis-scripts')
import Archook #The module which locates arcgis
Archook.get_arcpy(pro = True) # success! :)
import arcpy

May I suggest implementing a forced path argument as well that specifies "P"? :)

P.s., good job on this - I spent hours running into the constant issue of ArcGIS pro not wanting to copy the default environment; and this finally did the trick.

commented

Installing archook from Github worked for me.

pipenv install git+https://github.com/JamesRamm/archook.git#egg=archook

It did require me to create the registry keys manually though.

HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\ArcGISPro
 \PythonCondaEnv = arcgispro-py3
 \PythonCondaRoot = C:\Users\<username>\AppData\Local\Programs\ArcGIS\Pro\bin\Python
 \InstallDir = C:\Users\<username>\AppData\Local\Programs\ArcGIS\Pro

Where InstallDir is an Expandable String Value and the other two are String Value

It would be cool to be able to pass these 3 values as arguments to archook.get_arcpy