36
Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge

Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

HarnessingthePowerofPythoninArcGISUsingtheCondaDistributionShaunWalbridge

Page 3: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Python

Page 4: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhyPython?Accessiblefornew-comers,andthe

Extensivepackagecollection(56thousandon ),broaduser-baseStronggluelanguageusedtobindtogethermanyenvironments,bothopensourceandcommercialOpensourcewithliberallicense—dowhatyouwant

mosttaughtfirstlanguageinUSuniversites

PyPI

Page 5: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhyPython?Inthebox:

TheSciPyStack(NumPy,SciPy,Pandas,matplotlib,sympy)

xlrd,netCDF4,requests,PyPDF,pytz

ScientificProgrammingwiththeSciPyStack

Page 6: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

GettingtoPackages

Page 7: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhyPackages?Softwareiscomposedofmanysmallercomponents,oftencalledpackagesorlibraries.It’softenbettertoreusecodethatsolvesaproblemwellratherthanrecreatingitBut,sharingcodeisahardproblem.Doyouhavethesamepackagesofthesameversionsasthedeveloperdid?

Page 8: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

PackageManagementforPythonWhynotpip,wheels,virtualenvs?

Don’thandletheharderproblemofsystemdependencies,consideredoutofscopebyPythonpackagers—doesitendupinsite-packages?Packagedevs:OnOSXandLinux,‘easy’togetthedeps!Useasystempackagemanager(e.g.apt,brew,yum)andtheincluded

compiler(e.g.clang,gcc).It’sstillnoteasytomakereproduciblebuilds,andwhataboutWindows?

Page 9: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhataboutWindows?WeareparticularlystuckonWindowswhichlacksbroadlyusedpackagemanagementOnlydevelopershaveaCcompilerontheirmachineAhardproblem

EnterConda

Page 10: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhyConda?

ScientificPythoncommunityidentifiedthattherewasagapnotbeingaddressedbythecorePythoninfrastructure,limitingtheirabilitytogetpackagesintothehandsofusers

Industrystandardbuiltbypeoplewhocareaboutthisspace—ContinuumAnalytics

Page 11: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhyConda?

Itsolvesahardproblem:

Handlesdependenciesformanylanguages(C,C++,RandofcoursePython)BuiltforPythonfirst,butitreallysolvesamuchbroaderinfrastructuralissue.

E.g.UseitforisolatedRinstallations,whichareusuallytricky

Page 12: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Conda

Page 13: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Cross-platform:simplydeveloprecipesforbuildingandinstallingsoftwareonLinux,OSXandWindows.Opensource:Esriisusingit,youcanuseitinyourownprojectsforothercontexts

Whatcanitinstall?Notjustscientificpackages.Itcanhelpwith:

GUItoolkits(PyQt,TKinter)C++Libraries(Boost)IDEs(Spyder,Juptyer)

Page 14: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondainPro

Page 15: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Environments—AcollectionofpackagesandPythoninstalliscalledanenvironment,thebuildingblockformanagingPythonwithCondaFlexiblymakechangeswithoutaffectinginstalledsoftwareCancreatemultipleenvironmentsandswitchseamlessly

Requirements—includeexplicitstateinformation,notjustthepackagename.

Page 16: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsActivatingenvironments,acoupleways:

UsetheshortcutsincludedinProManuallyactivatetheenvironment:

cd C:\ArcGIS\bin\Python\Scripts activate arcgispro-py3

Page 17: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasics

Condainfoisthestartingpoint—ittellsyouthestateoftheenvironment.

conda --help

conda info

Page 18: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsDemo

Page 19: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsOnceyou’reinanenvironmentgetdetailswithinfo:

Condainfoisthestartingpoint—ittellsyouthestateoftheenvironment.

conda info

Page 20: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsconda info

Current conda install:

platform : win-64 conda version : 4.0.6 conda-build version : not installed python version : 3.5.1.final.0 requests version : 2.9.1 root environment : C:\ArcGIS\bin\Python (writable) default environment : C:\ArcGIS\bin\Python\envs\arcgispro-py3 envs directories : C:\ArcGIS\bin\Python\envs package cache : C:\ArcGIS\bin\Python\pkgs channel URLs : https://conda.anaconda.org/esri/win-64/ https://conda.anaconda.org/esri/noarch/ https://repo.continuum.io/pkgs/free/win-64/ https://repo.continuum.io/pkgs/free/noarch/ config file : C:\ArcGIS\bin\Python\.condarc

Page 21: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsconda list

# packages in environment at C:\ArcGIS\bin\Python\envs\arcgispro-py3:##colorama 0.3.7 py35_0 defaultscycler 0.10.0 py35_0 defaultsfuture 0.15.2 py35_0 defaultsmatplotlib 1.5.3 np111py35_0e [arcgispro] esrimpmath 0.19 py35_1 defaultsnetcdf4 1.2.4 py35_0e [arcgispro] esrinose 1.3.7 py35_1 defaultsnumexpr 2.6.1 np111py35_0e [arcgispro] esrinumpy 1.11.2 py35_0e [arcgispro] esripandas 0.19.0 np111py35_0 defaultspip 8.1.2 py35_0 defaultspy 1.4.31 py35_0 defaultspyparsing 2.1.4 py35_0 defaultspypdf2 1.26.0 py_0 esripytest 2.9.2 py35_0 defaultspython 3.5.2 0 defaultspython-dateutil 2.5.3 py35_0 defaultspytz 2016.6.1 py35_0 defaultsrequests 2.11.1 py35_0 defaultsscipy 0.18.1 np111py35_0e [arcgispro] esrisetuptools 27.2.0 py35_1 defaultssympy 1.0 py35_0 defaultswheel 0.29.0 py35_0 defaults

Page 22: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

CondaBasicsCreatingnewenvironments:

Afewdifferentways.Canmanuallyspecifythedependencies:

Canalsouseafilewhichincludesallthedependencies:

Thesecancontainexplcitinformationaboutchannels,toensurethatthenewenvironmentpreciselymatchestherequirements.

conda create --name my_env python=3.5 numpy flask dask

conda create --name my_env --file my_sweet_depends.txt

Page 23: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Condavs…Name Means Will

Ship?

Conda Thecommanditself ✓Miniconda AminimumsetofPythonpackagesto

buildandrunConda.✓

Anaconda Adistribution200+packagesbuiltwithConda

AnacondaServer

Hostthefullinfrastructureinternally

Page 24: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

DeeperDive

Page 25: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Demo:CondaPackage

Page 26: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

MultiplePythonsCurrently:

Platform Pythonversion

Desktop Python2.7(2.7.13)

Pro Python3.5(3.5.3)

Page 27: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

MultiplePythonsUpgradecode?

Doit!Youcansupport2+3withoutthatmuchworkStillneedtochangearcpy.mappingtoarcpy.mpwhenmovingfrom

DesktoptoPro,butnoPythonlanguagelevelchangesneeded....

But…thiscanbecostly.Formanyorganizations,asignificantburden,evenifthelanguagechangesarerelativelysmall.MultiplePythonsis

asolutiontothis.

PythonmigrationforArcGISPro

Page 28: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

ChallengesHavetomakesureyou’rerunningtherightPython(whathappens

whenyoutypepythonatthecommandline?)

WorkingtomakethiseasyaspossibleIt’llbeeasytotellinapp

Isolatedinstallationfixesavarietyofissues

Requiressomeusereducationoverthe“onlyonePythononthebox”model

Upgrades,whathappens?

Page 29: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhatDoIGetOutoftheBox?CondacommandandaCondarootPythoninstallNewmodules(e.g.requests)CondaenvironmentwithalloftheArcGISProdependenciesasCondapackages

Page 30: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

HowcanIusethis?ArcGISshipswiththeSciPystack—powerfulandoutoftheboxinallproductsCondacommandandaCondarootPythoninstallNewmodules(e.g.requests),environmentwithPro

PythonPackageManagerinPro...

Getpackages,expandyourpossibilityspace

Packageyourwork:thisisanopportunitytodistributeit

Page 31: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

WhereCanIRunThis?

ArcGISPro1.3:firstwithcondaArcGISPro2.0:

PythonPackageManagerPython3.5withcurrentpackageset

ArcGISEnterprise10.5ArcGISAPIforPython

Page 32: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

from future import *EffectivelymanagecomplexsoftwaredependencieswithConda.Thousandsofpackagesexisttoday,canintegrateitintoyourorganization’sneeds.

Page 33: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

Closing

Page 34: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

ThanksEsriCondaTeam:

ContinuumAnalyticsforcreatingandopensourcingConda

Page 35: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can

RateThisSessionPleasetakeoursurvey,findsessioninappandprovidereview

Page 36: Harnessing the Power of Python in ArcGIS Using the Conda … · 2017. 7. 11. · Harnessing the Power of Python in ArcGIS Using the Conda Distribution Shaun Walbridge. ... These can