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:
Other Observations (potential red herring though): This has all been ruled out as I can reproduce in multiple environments (completely different devices/workstations).
but lists the correct version of the arcgis module. The same AttributeError is returned in this configuration.
I trimmed down the code significantly should anyone want to try to reproduce.
I have also reproduced with with a built-in admin account as well as a domain user account with the Admin role in Enterprise. I have reproduced this from multiple environments.
Another update: I modified the script to also include:
import arcgis
print("arcgis API is version {0}".format(arcgis.__version__))
So I can confirm that no matter how the script is called, the correct/latest version of the arcgis API is indeed being used.
I get a different error myself, doesn't matter if I do stand alone with IDLE or notebook in Pro.
If I run it with Pro 2.9.3 with IDLE 3.7.11 (which reports "arcgis API is version 1.9.1") it says "'AGOLAdminManager' object has no attribute 'servers'"
If I run it with Pro 3.0.1, with IDLE 3.9.11 and reports "arcgis API is version 2.0.1" it runs fine and gives me a list of servers.
Default install environment, no clones.
R_
I should probably add a few points for clarity:
It's entirely possible the servers module was different at 1.9.1.
Could you try running from the command line (referencing the most recent API)? That's the key difference here (as far as all my testing has shown).
Had the same error message, it turned out admin module has more dependencies and some were missing (in my case pandas). Try putting:
import arcgis.gis.admin
in standalone script, and see what happens (I got as below, and installing pandas solved the problem)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Miniconda3\lib\site-packages\arcgis\gis\admin\__init__.py", line 9, in <module>
from .portaladmin import PortalAdminManager
File "C:\Miniconda3\lib\site-packages\arcgis\gis\admin\portaladmin.py", line 10, in <module>
from ...apps.tracker._location_tracking import LocationTrackingManager
File "C:\Miniconda3\lib\site-packages\arcgis\apps\__init__.py", line 4, in <module>
from . import survey123
File "C:\Miniconda3\lib\site-packages\arcgis\apps\survey123\__init__.py", line 3, in <module>
from ._survey import SurveyManager, Survey
File "C:\Miniconda3\lib\site-packages\arcgis\apps\survey123\_survey.py", line 10, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
import arcgis.gis.admin
I already had this in my script and It still tells me
AttributeError: 'GIS' object has no attribute 'admin'
Same issue as @ZacharyHart here. Federated server, SAML one identity login, tells me im logged in as an org_admin and cant access server list.
For the record ESRI Support told me that the issue is likely because our version of Enterprise was running 10.6