Yuav Paub
- Ntawm Python lub vev xaib, xaiv tus installer tshiab > ua raws li cov lus qhia > Install lossis Customization.
- Confirm: Qhib Terminal > hom python -- version. Terminal qhia Python version tus lej yog tias ua tiav.
Kab lus no piav qhia yuav ua li cas rau nruab qhov tseeb version ntawm Python programming lus mus rau Mac siv qhov tshiab tshaj plaws ntawm macOS.
Installing Python ntawm macOS
Python qhov project ua rau kev tso tawm tsis tu ncua ntawm Python hauv tus qauv. PKG hom. Ua raws li cov kauj ruam hauv qab no txhawm rau nruab tus qauv Python faib ntawm koj Mac:
- Tau qhov kev tso tawm tshiab kawg ntawm Python lub vev xaib. Tshwj tsis yog tias koj nyob hauv lub tshuab qub thiab yuav tsum tau siv lub version dhau los ntawm macOS rau qee qhov laj thawj, koj tuaj yeem rub tawm cov ntaub ntawv 64-ntsis installer.
- Qhov rub tawm yog tus qauv macOS. PKG hom. Nyem rau cov ntaub ntawv installer mus txuas ntxiv.
-
Thawj lub vijtsam muab qee cov ntaub ntawv ntawm kev teeb tsa. Nyem Continue mus ua raws.
-
Click Continue ntawm nplooj ntawv nram qab no ib yam nkaus, uas yog daim ntawv ceeb toom tias qhov project yuav tsum tsis txhob muab kev txhawb nqa rau 32-ntsis installers los ntawm v3.8 mus rau.
-
Lub vijtsam tom ntej hais kom koj lees txais daim ntawv tso cai qhib rau Python. Nyem Continue thiab mam li nias Agree.
- Xaiv qhov chaw rau kev teeb tsa ntawm lub vijtsam hauv qab no. Koj tuaj yeem nyem Install tso rau ntawm koj lub ntsiab tsav lossis nyem Customize tso rau lwm qhov.
-
Tam sim no tus installer pib luam cov ntaub ntawv, thiab qhov kev nce qib qhia koj thaum nws tiav.
- Thaum lub installation tiav lawm, lub app lub nplaub tshev qhib hauv Finder.
Qhia koj qhov kev teeb tsa Python
Txhawm rau kom paub meej tias koj qhov kev teeb tsa Python ua haujlwm raug, sim cov lus txib hauv qab no hauv Terminal:
python --version
Python 3.7.4
Yog tias koj xav paub ntxiv txog tej yam, sim khiav ib tsab ntawv Python yooj yim. Nkag mus (lossis muab tshuaj txhuam) cov lej hauv qab no rau hauv cov ntawv khoob thiab muab nws lub npe "hello-world.py":
print ("Hello World!")
Tam sim no, ntawm qhov hais kom ua, khiav cov hauv qab no:
python /path/to/hello-world.py
Nyob zoo ntiaj teb!
Yog tias koj tau txais cov txiaj ntsig saum toj no, koj qhov kev teeb tsa Python tshiab tau npaj mus.
Python Version rau nruab rau macOS
Python los ua ntej nruab rau ntawm macOS, tab sis qhov tsim-hauv version yog tshwj xeeb rau version ntawm macOS koj tab tom khiav tam sim no. Qhov no txhais tau tias nws tsuas yog hloov kho thaum koj tau txais OS hloov tshiab los ntawm Apple. Yog li, yog tias koj xaiv siv lub version tsim rau hauv macOS, koj tuaj yeem khiav ib qho version uas laus dua li tam sim no.
Koj lwm txoj hauv kev yog txhawm rau nruab qhov hloov tshiab ncaj qha los ntawm Python project. Ua li no los nrog nws tus kheej caveats, uas yog hais tias koj yuav tsum tau ceev nrog cov tshiab tso tawm ntawm koj tus kheej.
Ua ntej txiav txim siab qhov no, xav txog cov hauv qab no:
- Puas yog koj cov kev pabcuam Python tsuas yog rau koj tus kheej siv, ntawm koj tus kheej Mac? Yog hais tias yog li ntawd, lub built-in version tej zaum yuav txaus.
- Koj puas yuav tso koj cov kev pabcuam rau siv rau ntawm lub platform tshwj xeeb? Thaum qhov no yog qhov teeb meem, nws nyob ntawm seb lub platform taug qab Python tso tawm (lossis tsis yog). Yog tias koj tab tom tsom mus rau macOS nkaus xwb nrog koj cov cai, tom qab ntawd qhov tsim-hauv version yog qhov kev xaiv zoo, raws li koj ib txwm paub tias version koj siv yog qhov uas koj cov neeg siv yuav muaj thiab. Txawm li cas los xij, yog tias koj tab tom sau daim ntawv thov lub vev xaib, koj yuav tsum xav txog dab tsi version ntawm Python koj lub vev xaib hosting tuam txhab txhawb nqa.
- Qee qhov kev khiav haujlwm, xws li Linux, yuav ua raws li kev tso tawm tshiab tshaj plaws ntawm Python ze. Hauv qhov piv txwv no koj tuaj yeem siv cov ntawv tshiab tshiab, txhawm rau ua kom zoo dua ntawm cov yam ntxwv tshiab.