I have a geoprocessing script using ArcGIS API for Python that I've been using for several months. After upgrading to Pro 3.4, I can't do anything with the arcgis.gis module. I have Pro 3.3 installed on a different computer and the same script still works fine.
The script starts out as:
from arcgis.gis import GIS
gis = GIS("pro")
from arcgis.features import *
from arcgis.geometry import *
from arcgis.geometry.filters import within
import arcpy
def coordsCounty():
arcpy.AddMessage("Logged in as " + str(gis.properties.user.username))
I get an error on line 9, "AttributeError: module 'arcgis.gis' has no attribute 'properties'. I get errors on other arcgis.gis functions too, like a simple gis.content.get request that has never been problematic.
Package manager in Pro shows ArcGIS API for Python 2.4.0 is installed. I'm using a named user license through ArcGIS Online and it is the active portal in Pro.
Any ideas? Thanks.
There were lots of changes in the arcgis module, your scripts may have to be modified.
here is a deprecation list
arcgis-python-api/guide/02-api-overview/deprecation-notices.ipynb at master · Esri/arcgis-python-api
the changes in the most current version
arcgis-python-api/guide/02-api-overview/release_notes_240.ipynb at master · Esri/arcgis-python-api
and you can scroll back in time to previous versions from the links to the left of the page above
Thanks for sending the documentation, @DanPatterson. The Pro version that it still works on is 3.3, not 2.3 as I originally wrote in my post. Big difference! I don't see anything in the depreciation notices that would cause the issue. I'll put in a ticket with Esri support.
Pro 3.3 was using the api for pytho version 2.3 Pro 3.4 uses the api version 2.4 to clarify
For anyone else reading this, Esri logged a bug for this related to the geometry module. The workaround is to import the geometry modules individually instead of using a wildcard.
BUG-000173067 - Using a wildcard ('*') to import all from the arcgis.geometry module ("from arcgis.geometry import *") will output attribute error: "module 'arcgis.gis' has no attribute 'x" when running code with the ArcGIS API for Python version 2.4.
I am having a similar issue where our 2 scripts run perfectly in 3.3.2, but once we update to 3.4, they get errors and don't complete. Do you know if any of these would need to just be adjusted at the start of our script?:
import json, arcpy, shutil, os, requests
import csv
arcpy.env.overwriteOutput = True
import arcgis
from arcgis.gis import GIS
import datetime
from datetime import datetime
from datetime import date, timedelta
@eallan I'm a beginner so take anything I say with a grain of salt. Line 4 looks odd to me. Is that supposed to import every arcgis module? I would try commenting that out and see what happens.
Other than that, it might be a matter of trial and error. Commenting out sections of the script and the modules you're importing to determine where the issue is. I basically had to add lots of arcpy.addMessage entries to check which steps were completing properly. You can also read through the deprecation notices that Dan Patterson posted above.
Do you know where the script fails? Knowing that would be very helpful.
Thanks Jmax for those tips, much appreciated! I ended up finding this arcpy help information about signing into portals: SignInToPortal—ArcGIS Pro | Documentation
Our original scripts were signing into our portal using I think a variable (not sure if that is what the Portal text is below) and format:
Portal = GIS("https://webadaptorhost.domain.com/webadaptorname", 'username', 'password')
instead of just:
arcpy.SignInToPortal("https://webadaptorhost.domain.com/webadaptorname", 'username', 'password')
Our scripts our working perfectly fine now. Looks like that's all that I needed to change in 4 lines of our scripts.
Both scripts were originally developed by John Lucotch from Equinoxgeo.com based out of Montana, they're supposedly an ESRI bronze partner, and he had originally charged only $500 total for the 2 scripts (around 400 lines of code) that we have run on a schedule. But to fix just this minor issue, he was quoting us $1000 to change a little bit of text in just 4 lines of code, kind of weird.