Select to view content in your preferred language

GIS Object -- Py 2.7 or Py 3.x

713
2
Jump to solution
04-21-2023 05:03 AM
kapalczynski
Frequent Contributor

I am trying to use the GIS Object in python to query against my AGOL.  

Right now the only way I can get this to work is if I use .py 3.x

Is there a way to use this object from .py 2.7 with "import arcpy"?

 

from arcgis.gis import GIS
import arcgis

agol_username = 'xxxx' 
agol_password = 'xxxx'  
output_csv = r'C:\Users\ccc\Desktop\GIS_projects\AGOL_Python\UsersAboutToExpire.csv'
search_user = '*'

gis = GIS('https://xxx.maps.arcgis.com', agol_username, agol_password)
user_list = gis.users.search(query=search_user, max_users=2000)
roles = gis.users.roles.all()
rol_ids = {role.role_id: role.name for role in roles}
output = []

 

0 Kudos
1 Solution

Accepted Solutions
Kepa
by Esri Contributor
Esri Contributor

Hello @kapalczynski,

Firstly , I think you are mixing arcpy vs arcgis library. Both are completely different libraries with specific aim. arcpy focused on bringing desktop arcobjects tools ready to your python scripts and arcgis is the standard library to use on web-based GIS (management tasks, spatial analysis, etc.).

GIS Object (or class) is available only through arcgis library. In some Python environments (like in ArcGIS PRO's or Server's default env) you may use either of them depending on your workflow.

Secondly, Python 2.7 was officially retired in 2020, so stick to Py3.

Cheers,

View solution in original post

0 Kudos
2 Replies
Kepa
by Esri Contributor
Esri Contributor

Hello @kapalczynski,

Firstly , I think you are mixing arcpy vs arcgis library. Both are completely different libraries with specific aim. arcpy focused on bringing desktop arcobjects tools ready to your python scripts and arcgis is the standard library to use on web-based GIS (management tasks, spatial analysis, etc.).

GIS Object (or class) is available only through arcgis library. In some Python environments (like in ArcGIS PRO's or Server's default env) you may use either of them depending on your workflow.

Secondly, Python 2.7 was officially retired in 2020, so stick to Py3.

Cheers,

0 Kudos
kapalczynski
Frequent Contributor

OK thanks... Yea 3.x is the only one I can run it on.... Sadly our server is not there yet...  Thanks

0 Kudos