Python API unable to connect to AGOL

1950
3
Jump to solution
12-12-2018 05:30 AM
AllenGuan2
New Contributor III

I have been running the following python API in jupyter notebook to access our company AGOL for a while. But it breaks in the last few days. I heard ESRI is changing the authentication model, could this be related or the API call is outdated this week? It worked last week.

from arcgis.gis import GIS
gis = GIS(url="https://bhp.maps.arcgis.com/home", username='myadminaccount',password='myadminpassword',proxy_host='....', proxy_port='8081')

The errors are below:

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\__init__.py in <module>()

      1 __version__ = '1.4.1'      2 ----> 3 from . import features, geoanalytics, geocoding, geometry, geoprocessing, network, raster, realtime, schematics, mapping, apps      4       5 from .gis import GIS C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\__init__.py in <module>()     19 """     20 ---> 21 from .feature import Feature, FeatureSet, FeatureCollection     22 from .layer import FeatureLayer, Table, FeatureLayerCollection     23 from ._data.geodataset import SpatialDataFrame C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\feature.py in <module>()     13 from arcgis._impl.common._spatial import json_to_featureclass     14 from arcgis._impl.common._utils import _date_handler---> 15 from arcgis.geometry import BaseGeometry, Point, MultiPoint, Polyline, Polygon, Geometry, SpatialReference     16 from arcgis.gis import Layer     17  C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\geometry\__init__.py in <module>()     62 """     63 ---> 64 from ._types import *     65 from .functions import *     66 from . import filters C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\geometry\_types.py in <module>()      7 from six import add_metaclass      8 try:----> 9     import arcpy     10     HASARCPY = True     11 except ImportError:C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py in <module>()     70     import _initagsenv     71 ---> 72 from arcpy.geoprocessing import gp     73 from arcpy.geoprocessing import env     74 from arcpy.geoprocessing._base import gptooldoc as _gptooldoc C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py in <module>()     12 #     13 #email: contracts@esri.com---> 14 from ._base import *C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py in <module>()     12 #     13 #email: contracts@esri.com---> 14 import arcgisscripting     15 import functools     16  RuntimeError: Not signed into Portal.
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Allen: this is a misleading error that is actually being thrown by arcpy, not the ArcGIS API for Python. The API for Python will attempt to load arcpy if you are running your scripts in ArcGIS Pro. Since arcpy is a licensed part of ArcGIS Pro, it must properly detect the license associated with Pro. If you license Pro through a portal, you must have your ArcGIS Pro open and logged in to when running these scripts.

So try opening ArcGIS Pro, logging into your account, and then running this script again. If you're still running into errors, try upgrading the API and running it again (with Pro open). Let me know if this doesn't resolve your issue, thanks!

View solution in original post

3 Replies
by Anonymous User
Not applicable

Hi Allen: this is a misleading error that is actually being thrown by arcpy, not the ArcGIS API for Python. The API for Python will attempt to load arcpy if you are running your scripts in ArcGIS Pro. Since arcpy is a licensed part of ArcGIS Pro, it must properly detect the license associated with Pro. If you license Pro through a portal, you must have your ArcGIS Pro open and logged in to when running these scripts.

So try opening ArcGIS Pro, logging into your account, and then running this script again. If you're still running into errors, try upgrading the API and running it again (with Pro open). Let me know if this doesn't resolve your issue, thanks!

AllenGuan2
New Contributor III

David: Yes, found out my ArcGIS Pro license became unregistered. After re-registering, it works now. Many thanks.

0 Kudos
DougZietz1
New Contributor III

I am having a similar issue. However, I am using concurrent use licenses and my instance of Pro is becoming unlicensed for unknown reasons. The solution has been to re-license manually. This is a problem because I am running scheduled tasks which fail in the meantime. Is there a way to automatically re-license?

0 Kudos