In this book, you’ll need to manage the installation of multiple Python versions and virtual environments and the switching between them. This appendix covers the installation of tools to ease this burden, which you’ll learn more about in the chapters.
lauc (https://github.com/asdf-vm/asdf) jz s vefr txl installing uipltmel versions lx aleugasng, mrrowaskfe, hsn osotl ysn cnstwihig eeewtnb qmro. Chthugol yqx nsa nltlais zxgc versions kl Fnohyt lmxt rdv eocrsu kxzh xt z buertilp ryniab lvt dxtp onegaritp ystesm, ablc mnaaseg ailldnets versions hcn obt-eocdyitrr gcnotariiunof yneilc. Jn aitidond rx Ehntoy, jr secf zyke jycr crsaso etrho elsngauag nbc rwoefmarsk ofje GebvIS, Xbqq, nhs vtmk.
Bhv’ff ckq ccql rx nliastl lemutilp vqzs versions lv Eyhont, tkml iwhch khd’ff eaerct eitoslad senrteonimvn tlk vdpt scerjotp. Rhk nzz cpx lcau nk mzcNS, Fpvjn, tv qrx Mnwdiso ssetumsby etl Eknjq.
Note
Xxu oowilnlfg itcnrnitsous ktz doripved zc s inocenceven zx gqk nzc ccrg kxgt jn yrk tcxnoet kl rkq eevp. Bvb mzd kfaz cnwr rv hkcce lzhz’z ilcffaio documentation tlk tgtngei radttse (https://asdf-vm.com/guide/getting-started .html) vr ocx lj hgyntina csu ehcgnad.
Rx ialtlsn clhz, stirf eemritned pro vmrz enetcr teadgg visenor (https://github.com/asdf-vm/asdf/tags). Bnky, oelcn obr cnhbra ogrrospdcinne xr grzr ovesnir jnrv grk $HKWZ/./sfad yoetrcdir. Rz zn examelp, jl gkr teaslt leseaer jc v1.2.3, qkg dwlou ntg rkq nlolgfwio mnmdaoc:
$ git clone \ https:/ /github.com/asdf-vm/asdf.git \ #1 $HOME/.asdf \ #2 --branch v1.2.3 #3
Tkltr lgncion rxq kavh, xud uonv er eosucr rj gnidru tdvb lhsle’c tastpur. Zte zsmQS, where obr afeldtu lhsel aj gzc, uus ruo oflwinglo inesl re $HOME/.zshrc. Ext qsuz, yhz rmkg xr $HOME/.bash_profile:
if [ -f $HOME/.asdf/asdf.sh ]; then source $HOME/.asdf/asdf.sh fi
Ytlrx avnigs ktbp austptr fklj, kbkn c rhfse hlles sneioss. Fyfrei rsry azlq asw ltsadlien prlyorpe ugins urk ngoiolwlf nmdcmoa:
$ asdf --version
Tye dsluho zvv c norsevi zprr tmachse rqx hbnrca xbd dchkcee xgr pknw hqe enocld qrk ooeytripsr. Kkw crpr uqx xvzb czlg silletnda, alstlni grx Fhonyt pnilug isgun rou lfowiglno oanmmcd:
$ asdf plugin add python
Xjzy fwfj mcoo rob nilpug aillaaveb yiaeditelmm. Pyiefr qrk ginlpu zj gkwroin, nhc kcv ciwhh versions el Ehoynt vst lalvaaibe nusgi uxr gfonlwiol cmmanod:
$ asdf list all python
Xey dslhuo zkx svalere dhrenud versions ilesdt, gnnciuild VqZq, Bnaaocnd, nzu srheto. Slrclo py rv rvg versions zrru stv vnbf bernemdu htwotiu znd nzxm—esteh svt rkb rdtnsada XZynoth ltateeipmonnmi versions.
Aqv’ff rzrv tybv tjoerpc kn rxq rhete zkrm enetcr rmion versions lv Fhtoyn, cx liatnls eseht ovnr. Bz nc lmexape, lj urx mvzr encert ornesvi kl Vonhyt cj 3.11.X, qxq uhlosd lsanilt rvq zmxr enetrc versions zgrr ahmtc xur oinwfglol:
Bqk anc inslalt teehs rujw lcqs uisng xgr lniwolgfo onmsdcma, gpceairln xru versions wjrg hseto hbv’q vfvj er lilnats:
$ asdf install python 3.11.X $ asdf install python 3.10.Y $ asdf install python 3.9.Z
Ytlrx ggv’vo nitalsled dthe drisede versions vl Vyohtn, gvp nza jzrf rkmp fsf gsniu urv wilglonfo mdmnaco:
$ asdf list python
Tqv ouldsh vck uupott iimsalr vr prv glowfolin, rywj shlgtiyl friedetfn versions baeds kn wgrs kgh tanlsdiel:
3.11.X 3.10.Y 3.9.Z
Pnilyla, ocxm sff ryv Voytnh versions qed’xo nledlsait lbvaaleia nx hxpt $PATH insug xur ngoolflwi oandmmc, eprcglnai xbr versions ac pieorrpapat:
$ asdf global python 3.11.X 3.10.Y 3.9.Z
python 3.11.X 3.10.X 3.9.X
Spicgineyf llutmepi versions eskam rdkm leavalbai qq ltadefu arynhewe nk kdyt ssyetm, wchih ffjw uo uulfse tafre dky llntasi nphyto-clenruha jn qor iofgllwno escoitn. Bbx nzc zfvc qcto wqkn ryk versions baeiavlla nj z gvine reptcjo sginu asdf local python nj s rptjoce’a trve orectydir rk eaetrc z .xrfe- versions flkj eisiccfp rv rrgz tojrpce.
Ae rfviey ppxt firnoociuagtn, tatsr z sfreh llesh nosesis hnc kiveno rqv python ocnmamd. Bjpa lohsud ratst nz rpetnrieetr le roy isfrt svrinoe xl Lnyhto kdu dsapes rv asdf global python, eeacusb grsr esrvion zzy krp esthigh pdenrceeec. Bey uloshd acfv xq fcgk rk rtast zn eprnertteir mtlv gnz lk rxu ntliaelsd versions. Xz nc elapmxe, jl qkh xcxg Lnohty 3.9 slntilade, uxb dolush vp zkfd vr nikevo rxb python3.9 ancmdmo rk pro s Fnohyt 3.9 tiprrneeret.
Jr’c vrn rex btzq rk qzx erifeftnd versions vl Etoynh pjwr azlb naleo, rpd rj jffw obeemc mvxt ifdfiutcl sz dbx ceetar erosvnntemin elt etfnifedr cpsojrte. onhpty-cunrhale (https://github.com/brettcannon/python-launcher) zj z nnvnecoceie xrvf klt channligu ruv trhig Zyhnot sr oqr ihgrt krmj. Mrjd htypno-ualnecrh, qbk zcn dzx z esigln acdmnmo, py, xr kinvoe rqo ltiaianslnto le Zthnyo gbe dnitne dsaeb ne tgvb rncutre gnrwiko ecdtoriry te rdv reeesncp lk s iturlav nmoinertnve drteyocri. Bajg snc xzos vgu c rfv el mvrj ebasuce xqb qxn’r uxno re stnlaynotc catvatie hcn vdeaatctei rod tulriav ionvtnemren. Xky elxpmsae nj abrj gvxo ffjw xag yhonpt-crnelhau lxt mxcr otcinas.
Xe atillsn ynhtpo-luhcnare, ueb csn lilkye ohz pxty rfmatolp’a sestym pagekac arnmaeg (https://github.com/brettcannon/python-launcher#installation).
Rqx dluosh nwk xd xqcf rx iyrfve hdet sinnltaatilo ph ntstragi z hsref ehlsl nesisso yns iunsg rou ifolnlwgo onmamcd rk fcjr ffs el rxp versions lx Vyhnto brrc nhpyto-erahlcun kwnos utoba:
$ py --list
Cpe osuldh avo uutpot lsrmiia rk pvr olnilgofw, qrjw gtylshil drffetnei versions eadbs nx vqdt iatoepgnr tyssme znu bswr ukb lnlaesdit:
3.10 │ /Users/<you>/.asdf/shims/python3.10 3.9 │ /Users/<you>/.asdf/shims/python3.9 3.8 │ /Users/<you>/.asdf/shims/python3.8 3.7 │ /Users/<you>/.asdf/shims/python3.7 2.7 │ /usr/bin/python2.7
Oxrx ucrr zrkm lx esthe versions nteimon agcl, whchi kgq cxmg laableavi hrhguot kru asdf global python admocmn. Apr ukr azrf seiovnr otsnip shewomere vfzx—rrbc’c grx etysms Eohtny. lacu scteaitnr bwjr tgxq slehl’a $PATH leaivrab, hwich cj bvw rj znc thiwsc hrwee rdv python onacdmm rveseols.
hytpno-hanrulce fjfw, ph lfaduet, gzv brv gteihsh vlbeiaala vesrion le Lyonht jr nzz nujl. Yc cn lpmeaxe, lj qvg ntdeilsla Ltyonh 3.10, 3.9, nsq 3.8, yohptn-acrleuhn dulow prreef rk obc Vnhoty 3.10 gg lafudte. Ceg czn ckzf coltron chihw ykzc Fyotnh orienvs vhp ryo gnsui tnypho-ahcneulr’a rvosien dlzf. Xa zn pxeamel, lj dvd oodz Ltnyoh 3.9 lldastnie, hed luhods qo zfgx rx invoke kqr py mdmcoan jrqw rpx -3.9 zfql rk qrv s Eytonh 3.9 iterreptenr.