Unable to import ArcGIS Python library

625
2
02-02-2022 03:35 PM
sullivani
New Contributor III

Hi, I have just started looking at using the ArcGIS API for Python library, but I have hit an issue immediately.

Attempting to import the library results in the following error:

from arcgis.gis import GIS

Traceback (most recent call last): 
  File ".\main.py", line 1, in <module>                                                                                                  
    from arcgis.gis import GIS
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\__init__.py", line 4, in <module>
    from . import features, geoanalytics, geocoding, geometry
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\features\__init__.py", line 26, in <module>
    from .feature import Feature, FeatureSet, FeatureCollection
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\features\feature.py", line 25, in <module>
    from arcgis.gis import Layer
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\gis\__init__.py", line 31, in <module>
    from arcgis.gis._impl._con._helpers import _is_http_url
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\gis\_impl\_con\__init__.py", line 1, in <module>
    from ._connection import Connection
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 26, in <module>
    certifi_win32.generate_pem()
  File "C:\Users\user\PycharmProjects\sqm_arcgis\venv\lib\site-packages\certifi_win32\wincerts.py", line 113, in generate_pem
    os.makedirs(os.path.dirname(PEM_PATH))
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\\Users\\user\\AppData\\Local\\.certifi'

I tried a number of things to solve this issue - deleting the folder and even reinstalling Python and the ArcGIS library, but still the issue occurs.

Has anybody run into the same  problem before? I only have this issue on Windows 10, I haven't had the same issue on Linux. I have even tried on multiple Windows 10 machines, which resulted in the same error each time.

Thanks

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

do you have the correct version installed for windows?

arcgis .... anaconda site


... sort of retired...
0 Kudos
GeorgePovoas
New Contributor

Delete this file:

C:\\Users\\user\\AppData\\Local\\.certifi

It worked for me!

0 Kudos