{"id":9487,"library":"arcgis","title":"ArcGIS API for Python","description":"The ArcGIS API for Python is a powerful, open-source library for working with GIS data and services. It provides a rich set of tools for spatial analysis, data management, and mapping, enabling automation and scripting workflows with ArcGIS Online and ArcGIS Enterprise portals. The current version is 2.4.2, and it follows a regular release cadence with several updates per year, often aligning with major ArcGIS platform releases.","status":"active","version":"2.4.2","language":"en","source_language":"en","source_url":"https://github.com/Esri/arcgis-python-api","tags":["gis","mapping","esri","spatial","geospatial"],"install":[{"cmd":"pip install arcgis","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"GIS is part of the gis submodule, not directly under arcgis","wrong":"from arcgis import GIS","symbol":"GIS","correct":"from arcgis.gis import GIS"},{"note":"SpatialDataFrame was moved from arcgis.geometry to arcgis.features in version 1.5","wrong":"from arcgis.geometry import SpatialDataFrame","symbol":"SpatialDataFrame","correct":"from arcgis.features import SpatialDataFrame"}],"quickstart":{"code":"import os\nfrom arcgis.gis import GIS\n\n# Connect to ArcGIS Online or a specific portal\n# It's recommended to store credentials securely, e.g., using environment variables or secret management.\n# For ArcGIS Online, use 'https://www.arcgis.com'\n# For ArcGIS Enterprise, use your portal URL, e.g., 'https://yourportal.com/portal'\n\n# Option 1: Anonymous access (limited)\n# gis = GIS()\n\n# Option 2: Connect using username and password (for scripting)\n# Replace with your actual credentials or retrieve from secure storage\nportal_url = os.environ.get('ARCGIS_PORTAL_URL', 'https://www.arcgis.com')\nusername = os.environ.get('ARCGIS_USERNAME', 'YOUR_USERNAME')\npassword = os.environ.get('ARCGIS_PASSWORD', 'YOUR_PASSWORD')\n\nif username == 'YOUR_USERNAME' or password == 'YOUR_PASSWORD':\n    print(\"Warning: Please set ARCGIS_USERNAME and ARCGIS_PASSWORD environment variables or replace placeholders.\")\n    # Attempt anonymous access if credentials aren't set\n    try:\n        gis = GIS(portal_url)\n        print(\"Connected anonymously to \" + gis.url)\n    except Exception as e:\n        print(f\"Failed to connect anonymously: {e}\")\n        gis = None\nelse:\n    try:\n        gis = GIS(portal_url, username, password)\n        print(\"Logged in as \" + gis.properties.user.username + \" to \" + gis.url)\n    except Exception as e:\n        print(f\"Failed to connect with credentials: {e}\")\n        gis = None\n\nif gis:\n    # Example: Search for content\n    items = gis.content.search(query=\"type:'Web Map'\", num_items=5)\n    for item in items:\n        print(f\"- {item.title} ({item.owner})\")\n","lang":"python","description":"Demonstrates how to connect to ArcGIS Online or an ArcGIS Enterprise portal using the GIS object. It shows how to authenticate and perform a basic content search. It is highly recommended to use environment variables for sensitive credentials."},"warnings":[{"fix":"Update your code to use the direct properties and methods on `gis.users`, `gis.groups`, and `gis.content`. For example, replace `gis.content.manager.search()` with `gis.content.search()`.","message":"Version 2.0.0 (March 2021) introduced significant API changes, particularly in how users, groups, and content are managed. Direct access to `manager` objects (e.g., `gis.users.manager`) was removed in favor of direct properties/methods (e.g., `gis.users.search()`).","severity":"breaking","affected_versions":"1.x to 2.0.0+"},{"fix":"Replace calls to `gis.map()` with `gis.map_view()`.","message":"The `gis.map()` method for creating map widgets was deprecated in version 2.0.0 and replaced by `gis.map_view()`. While `gis.map()` might still work in some contexts, `gis.map_view()` is the recommended and actively maintained approach.","severity":"deprecated","affected_versions":"2.0.0+"},{"fix":"Review the API reference for the 2.x series and update import paths for affected modules (e.g., `from arcgis.features import geoenrichment` instead of `from arcgis import geoenrichment`).","message":"Several modules and classes were reorganized or moved in version 2.0.0. A notable example is `arcgis.geoenrichment` moving to `arcgis.features.geoenrichment`.","severity":"breaking","affected_versions":"1.x to 2.0.0+"},{"fix":"Configure trusted root certificates on your system, or for development/testing, you can temporarily set `verify_cert=False` in the `GIS` constructor (e.g., `gis = GIS(url, verify_cert=False)`). *Caution: Disabling certificate verification is not recommended for production environments.*","message":"In enterprise environments, SSL certificate verification issues (e.g., self-signed certificates or corporate proxies) can prevent successful connections. This often manifests as `requests.exceptions.SSLError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Remove the `.manager` attribute. For example, change `gis.content.manager.search()` to `gis.content.search()` and `gis.users.manager.get()` to `gis.users.get()`.","cause":"Attempting to access a 'manager' attribute on GIS object properties (like gis.users.manager) which was removed in version 2.0.0.","error":"AttributeError: 'GIS' object has no attribute 'manager'"},{"fix":"Update your import statement from `from arcgis import geoenrichment` to `from arcgis.features import geoenrichment`.","cause":"The `geoenrichment` module was moved from `arcgis.geoenrichment` to `arcgis.features.geoenrichment` in ArcGIS API for Python version 2.0.0.","error":"ImportError: cannot import name 'Geoenrichment' from 'arcgis.geoenrichment'"},{"fix":"Double-check your `username`, `password`, and `portal_url`. Ensure the user has the necessary permissions to access the portal. Verify network connectivity to the portal URL.","cause":"The credentials provided to the `GIS` object constructor are incorrect, or the portal URL is inaccessible/incorrect.","error":"ValueError: Invalid username or password"},{"fix":"Ensure the necessary root certificates are trusted by your system. For testing, you can pass `verify_cert=False` to the `GIS` constructor (e.g., `gis = GIS(url, username, password, verify_cert=False)`). *Use with caution and only in controlled environments.*","cause":"The Python environment cannot verify the SSL certificate of the ArcGIS portal. This is common with self-signed certificates or corporate proxies.","error":"requests.exceptions.SSLError: HTTPSConnectionPool(...): Max retries exceeded with url: ... Failed to establish a new connection: [SSL: CERTIFICATE_VERIFY_FAILED]"}]}