The ArcGIS API for Python is distributed as a conda package named arcgis . Conda is a popular Python package and environment manager application that helps you ...
ArcGISAPIforPythonHomeSamplesAPIReferenceMenuOverviewKeyfeaturesInstallandSetupSystemrequirementsPythonenvironmentsReleasenotesUsingtheAPITheGISWorkingwithgeometriesFeaturedataandanalysisIntroductiontoDataEngineeringinPythonWorkingwiththeSpatiallyEnabledDataFrameEnrichingGISdatawiththematicinformationImageryandrasteranalysisWorkingwithBigDataUsinggeoprocessingtoolsFindingplaceswithgeocodingPerformingnetworkanalysesMappingandvisualizationManagingArcGISapplicationsDeepLearningwithArcGISNavigationMenuInstallandSetup
WorkwithmapsandgeospatialdatainPythonusingTheArcGISAPIforPython.
UsesimpleandefficienttoolspoweredbyWebGIS,forsophisticatedvectorandrasteranalysis,geocoding,mapmaking,routinganddirections.Administer,organizeandmanageusers,groupsandinformationitemsinyourGIS.
Thislibraryenablesaccesstoready-to-usemapsandcuratedgeographicdatafromEsriandotherauthoritativesources,andworkswithyourowndataaswell.ItintegrateswellwiththescientificPythonecosystemandincludesrichsupportforPandasandJupyternotebook.
Seebelowforoptionstoinstallarcgisanditsdependencies:
TherearemultiplewaysinwhichyoucanexperiencetheArcGISAPIforPython.TheArcGISAPIforPythonisdistributedasacondapackagenamedarcgis.CondaisapopularPythonpackageandenvironmentmanagerapplicationthathelpsyouinstallandupdatepackagessuchastheArcGISAPIforPythonandtheirdependencies.
InstallationforArcGISPro2.5.xandlater¶
PythonhasarichcollectionofpackagesthatcanbeusedinArcGISPro.TosimplifytheuseofPythonpackages,ArcGISProincludesapackagemanagementsystemcalledconda.Condatakestheguessworkandhassleoutofinstallingandupdatingpackagesandtheirdependencies.
TofurtherextendtheversatilityandutilityofPythonpackages,multipleinstallationsofPythoncancoexistonasingleworkstation,independentofoneanother.EachoftheseinstallationsisreferredtoasaPythonenvironment.EachPythonenvironmentcanhaveitsownsetofpackages,allowingyoutoswitchbetweensetsofPythonfunctionalitywithoutuninstallingandreinstallingpackageseachtime.
Bydefault,ArcGISProhasasinglecondaenvironment,arcgispro-py3,whichincludesallPythonlibrariesusedbyArcGISProaswellasseveralothers,suchasscipyandpandas.
InstallationusingPythonPackageManager¶
ArcGISPro2.5andlaterreleasesshipwithcondaandthearcgispackagepre-installed.ThefunctionalityofcondaisintegratedintoArcGISProthroughthePythonPackageManager.ThePythonPackageManagerremovesmanyofthehurdlesfacedwhenwritingPythoncode.Itsupportsinstallingopen-sourceandthird-partylibrariesthatareassociatedwithanindividualproject,ratherthanthebasePythoninstallation.ThissimplifiestheprocessofsuccessfullysharingcomplexPythontoolsacrossmultiplecomputers.
ArcGISPro2.5andlaterprovidethePythonPackageManagerGUItodownloadandinstallanycondapackage.AccessitthroughtheArcGISProbackstagearea:
OpenArcGISProwithanewblankProject
SelecttheProjecttabtoaccesstheProbackstage(seescreenshotbelow)
SelectthePythonmenuoption
Youwillseethealreadyinstalledpackagesinthedefaultarcgispro-py3environment.Inordertoaddmorepackages,youcandothefollowing:
clickonManageEnvironments,clickNew
TypeanameforthenewenvironmentandclickSave
Allowblueprogressbaratthebottomofthedialogtocomplete.Proceedingbeforethiscompletescouldresultinanincompleteenvironmentthatmaynotperformproperly.
SelecttheActiveradiobuttontomakethenewenviromentactive
Clickon'AddPackages'buttonandtypepackagenameintothesearchbar.
Selectthereleaseyouwanttoinstall.
Click'Install'andacceptthetermsandconditions
Note:Youmayhavetoclickthe'refresh'buttontoensureyougettheupdatedpackageinformation.
InstallationusingPythonCommandPrompt¶
ArcGISProprovidesthePythonCommandPrompttodownloadandinstallanycondapackage.
NavigatetoStartMenu>AllPrograms>ArcGIS>PythonCommandPrompt
Note:Bydefault,thePythonCommandPromptopensintheArcGISProdefaultarcgispro-py3environmentdirectory,usuallyC:\ProgramFiles\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\,withthedefault
condaenvironmentactive.
Inordertoaddmorepackages,youneedtocreateacloneofthedefaultarcgispro-py3environment.Followthestepstocreateenvironment.Youcanchangethedefaultenvironmenttotheclonedenvironmentusingthecommand:proswap.Alternatively,toworkwiththeactivatedenvironment,usecondautilitytoactivateotherenvironments.
Enterthefollowingattheprompt:
condainstall-cesriarcgis=
Upgradepackage¶
ToupgradearcgispackageusingPythonPackageManager:
OpenArcGISProwithanewblankProject
SelecttheProjecttabtoaccesstheProbackstage(seescreenshotbelow)
SelectthePythonmenuoption
UsetheProjectEnvironmentdropdowntochooosetheappropriateenvironment
SelecttheUpdatePackagesoption
Choosetheappropriatearcgisreleasefromthelistofpackageswithrecentupdates
ClicktheUpdatebutton#thebuttonisdisabledifallthepackagesareuptodate.
ToupgradeusingPythonCommandPrompt,OpenPythonCommandPrompt
Activatetheenvironmentcontainingthearcgispackageandtype:
condaupgrade-cesriarcgis
InstallationusingAnacondaforPythonDistribution¶
conda¶Openaterminalapplication,navigatetothedirectoryyouwanttoworkin,andactivatethecondaenvironmentyouwanttousewiththeArcGISAPIforPython.InstalltheAPIwiththefollowingcommand:
condainstall-cesriarcgis
Note:Youcanalsousethe-nflagtoinstallthepackageintoanenvironmentofyourchoosing.
Formoredetials,readhere.
Pipenv¶PipenvistheofficialpackagingtoolformanagingenvironmentsandinstallingpackagesfromthePythonPackageIndex(PyPI).ToinstalltheArcGISAPIforPythonfromPyPIinanewenvironment,createanewfoldernamedyour-folder.Then,openaterminal,andruncd/path/to/your-foldertochangedirectoriesintoyour-folder.Next,enterthefollowingcommandtosimultaneouslycreateanewenvironmentandinstalltheAPIinit:
pipenvinstallarcgis
Installwithminimumdependencies¶Bothcondainstall-cesriarcgisandpipinstallarcgiswillinstallallofthedependenciesoutlinedinthesystemrequirementssection.However,theAPIcanfunctionina'strippeddown'statewithonlyafewdependencies.ThisallowsdeveloperstodeploytheAPIwithminimalfootprintinspaceconstrainedenvironments.Forthistowork,youneedtomanuallymanagethedependenciesinyourenvironmentbasedontheapplicationsyouneedtosolveandifyoudon'twanttouseeveryfeatureoftheAPI.Asofv1.8.3ofthePythonAPI,theminimumdependenciesneededare:
ujson
six
requests
Thislibraryhasitsowndependenciesthatmustbeincluded
requests_toolbelt
requests_ntlm
Thislibraryhasitsowndependenciesthatmustbeincluded
ntlm_auth
ToinstalltheAPIwithnodependencies,simplyaddthe--no-depsflagtoanyinstallcommand,i.e.condainstall-cesriarcgis--no-depsorpipinstallarcgis--no-deps.
TheabovesetofdependenciesshouldallowyoutoestablishaconnectionwithyourwebGISandperformanumberofadministrativeandothertaskswhichinvolveprocessingonyourGISratherthaninyourPythonkernel.DependingonyourOS,thissetupwithminimaldependenciesshouldtakeupabout50mbinspace.Asyourneedsexpand,youcanthenmanuallychoosewhichdependenciestoaddtoyourPythonenvironment.Forinstance,youcaninstallpandasifyourequiretoworkwithspatiallyenabledDataFramesandjupyter,ifyouneedthenotebookIDE.
InstallationasaDockerimage¶Dockerisapopularcontainerizationtechnology.Dockercontainersbundlesoftwareinacompletefilesystemwitheverythingthatisneededtorunit.Dockercontainersrunthesameregardlessofyouroperatingsystem.Tolearnmoreaboutdocker,refertotheofficialdocumentation.
TheArcGISAPIforPythonisshippedasaDockerimagewhichyoucandownloadandpowerupwheneveryouwanttousetheAPI.Theseimageswhenspunupintocontainers,runinanisolatedenvironmentwithoutmakinganychangestoyourlocalfilesystem.
FollowthestepsbelowtogetDockeronyourcomputerandruntheAPI:
Downloaddockerandinstallitonyourcomputer.
Onceinstalled,runthefollowingcommandinterminaltopullDockerimage
dockerpullesridocker/arcgis-api-python-notebook
Thenspintheimageintoacontainerusingthefollowingcommandinterminal.Replacethewithanavailableportnumber,forinstance8889.
dockerrun-it-p:8888esridocker/arcgis-api-python-notebook
Whenthecontainerstarts,itwillprovideaURL(withaonetimetoken)toopenyourlocalNotebookinstance.CopytheURLandpasteitinyourbrowser'saddressbartousethenotebooks.
InstallOffline¶1.Whileinaconnectedenvironment,downloadtheappropriatesoftwareyou'llneed:¶
thelatestversionofthefullAnacondaforPython3xforyourOS
theappropriateversionoftheAPIforPythonpackageforyourOSfromEsri'schannelonanaconda.org
Thefilenamesappearinthispattern:platform/arcgis-x.x.x-pyZZyyyyyyy-y.tar.bz2.Findyourfilebysubstituting:
youroperatingsystemplatformforplatform
theAPIreleasenumberforx.x.x
yourPythonversionforZZ.
Theyyyyyyy_yreferstoahashnumbercreatedforeachcondapackageuploadedtothechannel
Forinstance,ifyouareinstallingthePythonAPI1.6.2onWindows64-bitforPython3.7,downloadthewin-64/arcgis-1.6.2-py37h42bb103_633.tar.bz2package.
2.ConfigureAnacondaforuseinthedisconnectedenviroment:¶
InstallAnacondafromyourinstalllocation.Onceinstalled,youcanusetheAnacondaNavigatorGUIapplicationortheAnacondaPromptcommandlineconsoletooperatethesoftware.TheprocedurebelowoutlinesusingtheAnacondaPromptandthecondautilityonWindows:
First,openAnacondaPrompt.Allsubsequentcommandsareruninsidethisprompt:
Start>Anaconda3(64-bit)>AnacondaPrompt
ConfigureAnacondaforofflineuse.SeeCondaConfigurationforfulldetails:
condaconfig--setofflineTrue
Createanewenvironment,includingpythonandsixpackages:
condacreate-npythonsix
Activatetheenvironment:
condaactivate
InstalltheAPIforPythonpackage,havingdownloadedthebz2filethatmatchestheappropriateplatform,PythonversionandAPIreleaseyouareusing:
condainstall/path_to_package_download_folder/platform/arcgis-x.x.x-pyZZyyyyyyy-y.tar.bz2
ThecondautilitywillpullallthearcgispackagedependenciesfromtheinstalledsetofAnacondalibrariesinsteadofsearchingtheinternet.
3.Verifytheinstall:¶
Atthispoint,allmodules,classesandfunctionsareavailableintheAPIforuseinyourPythonscriptsorJupyternotebooksexcepttheMapWidget.YoucanverifyyourinstallbymakingaconnectiontoyourGISandprintingproperties:gis=GIS("url_to_your_gis","username","password")
print(f"Connectedto{gis.properties.portalHostname}as{gis.users.me.username}")
ThemapwidgetisonlysupportedwithinJupyterapplications.Followtheseadditionalstepstousethemapwidgetinadisconnectedenvironment:
installthejupyterlabpackageforvisualizingwithmapsineitherJupyterNotebookorJupyterLab:
condainstalljupyterlab
enablethemapwidgetbyrunningthese2commandsinsuccession:
jupyternbextensionenable--py--sys-prefixwidgetsnbextension
jupyternbextensionenable--py--sys-prefixarcgis
proceedtoTestyourinstallwiththeJupyterNotebooktoverifytheproperinstallationofthemapwidget.
NOTE:YoumayneedtoconfigurethemapwidgettousetheJavascriptAPIshippedwiththeportalyou'reconnectingtointhedisconnectedenvironment.Ifgis.map()doesnotreturnamap,runthefollowingcodetoconfigurethemapwidgetwiththeJavascriptAPIshippedwiththeportal:
MapView.set_js_cdn("https://your-portal-host/jsapi4/")
NOTE:TheWebGISmusthaveaGeocoderconfiguredasaUtilityServicetodisplayamap.Seeherefordetailsifyourportaldoesnothaveone.
Installationforolderversions¶
Youcanclickheretoinstallarcgisforolderversions.
Installdeeplearningdependencies¶
Ifyoualreadyhaveanenvironmentwiththearcgispackageinstalled,youcanfurtherinstallitsdeeplearningdependenciestotakeadvantageofthearcgis.learnmodule.Someofthedeeplearningsamplesavailableherecanbereferencedtounderstandtheworkflow.
Note:TousethedeeplearningcapabilitiesinArcGISPro2.9/ArcGISAPIforPython1.9.0onwards,theminimumrequiredversionoftheNvidiaGPUdriveris456.38.
UsingtheDeepLearningFrameworksInstaller¶ToworkwiththedeeplearningtoolsinArcGISPro2.6andlater,youneedtoinstallsupporteddeeplearningframeworkspackages.
DeepLearningLibrariesInstallerforArcGISisnowavailableathttps://github.com/Esri/deep-learning-frameworks.Thisinstallerincludesabroadcollectionofcomponents,suchasPyTorch,TensorFlow,Fast.aiandscikit-learn,forperformingdeeplearningandmachinelearningtasks.NotethatthiswillinstallthedeeplearningframeworksintoyourcurrentlyactiveProPythonenvironment;ifyouwishtoinstallinanenvironmentasidefromthedefaultarcgispro-py3environment,switchtothatenvironmentbeforerunningtheMSIusingeitherArcGISPro'sPythonmanagerUIoronthecommandlinewithproswap.Anysubsequentclonesofthatenvironmentwillalsoincludethisfullcollectionofpackages.
ForinstructionsonhowtoinstalldeeplearningframeworksmanuallyoroverArcGISImageServer,clickhere.
InstallusingPythonCommandPromptorAnaconda¶
ForArcGISProusers:¶
Deeplearningframeworks
canbeusedtoinstallalltherequireddependenciesinArcGISPro'sdefaultpythonenvironmentusinganMSIinstaller.
Alternatively,
foraclonedenvironmentofArcGISPro'sdefaultenvironment,deep-learning-essentialsmetapackagecanbeusedtoinstalltherequireddependencieswhichcanbedoneusingthefollowingcommand,inthePythonCommandPrompt(includedwithArcGISPro):
condainstall-cesrideep-learning-essentials
ForAnacondausers(Windows&Linuxplatforms):¶
arcgis_learnmetapackagecanbeusedforbothwindowsandlinuxinstallationsofAnacondainanewenvironment.
ThefollowingcommandwillupdateAnacondatothelatestversion.
condaupdateconda
Afterthat,metapackagecanbeinstalledusingthecommandbelow:
condainstall-cesriarcgis_learnpython=3.7
Note:Pythonversion3.6and3.8arealsosupportedwiththiscommand.
Testyourinstallwithjupyternotebook¶
Toverifyyourarcgisinstallation,runthefollowingcommandsinjupyternotebook:
Input
fromarcgis.gisimportGIS
my_gis=GIS()
m=my_gis.map()
m
Output
Toverifydeeplearningenvironment,runthefollowingcommands:
importfastai
importtorch
importarcgis
RunthiscommandtocheckifcudadeviceispickedupfortrainingamodelonGPU.
torch.cuda.is_available()
torch.zeros((3,224,224)).cuda()
Note:Ifyoufaceanerrorpointingtosomeissuewithdriver,youneedtoupdatedriver.
ThisoverviewdescribeshowtouseArcGISAPIforPythontowritePythoncode,incorporatingcapabilitiessuchasmapping,query,analysis,geocoding,routing,portaladministration,andmore.Browsethesamplenotebookstogetstarted.YoumaychoosetoexperiencethesesamplenotebooksinaliveenvironmentastheyareavailableasArcGISNotebooks.
Thesearetemporaryenvironmentswhichareerasedafteryouclosethebrowsertab.Ifyouwouldliketosaveyourchanges,downloadyournotebooksfromtheFilemenuoftheJupyternotebookIDE.
InstallationforArcGISPro2.5.xandlaterInstallationusingPythonPackageManagerInstallationusingPythonCommandPromptUpgradepackageInstallationusingAnacondaforPythonDistributionInstallwithminimumdependenciesInstallationasaDockerimageInstallOfflineInstallationforolderversionsUsingtheDeepLearningFrameworksInstallerInstallusingPythonCommandPromptorAnacondaTestyourinstallwithjupyternotebookShowtableofcontentsInstallationforArcGISPro2.5.xandlaterInstallationusingPythonPackageManagerInstallationusingPythonCommandPromptUpgradepackageInstallationusingAnacondaforPythonDistributionInstallwithminimumdependenciesInstallationasaDockerimageInstallOfflineInstallationforolderversionsUsingtheDeepLearningFrameworksInstallerInstallusingPythonCommandPromptorAnacondaTestyourinstallwithjupyternotebookWasthispagehelpful?YesNoWasthispagehelpful?YesNoYourbrowserisnolongersupported.Pleaseupgradeyourbrowserforthebestexperience.Seeourbrowserdeprecationpostformoredetails.