the following code produces the error: AttributeError: 'GIS' object has no attribute 'admin' but only in a stand alone script executed from the command line. The identical code works fine in Jupyter lab as well as the Python window in Pro.
Trimmed down the code in case anyone wants to attempt to replicate on their end.
#Import Modules
from arcgis.gis import GIS
##Log into Enterprise
gis1 = GIS("https://website.com/portal", username = "user@company.com", password = "password", verify_cert=False)
print("Logged in as: " + gis1.properties.user.username)
#Create server object
gis_servers=gis1.admin.servers.list()
server1 = gis_servers[0]
Fails at line 9.
The user is an administrator.
Additional Details:
- ArcGIS Pro 3.0.2 using a cloned environment
- ArcGIS API version 2.0.1
- Behavior is the same whether I run via python.exe or propy.bat
- I use stand alone scripts along with task scheduler all the time
- Modifications to the OS System Environment Variables does not fix this
Other Observations (potential red herring though): This has all been ruled out as I can reproduce in multiple environments (completely different devices/workstations).