找回密码
 会员注册
查看: 46|回复: 0

macpython下载安装教程,python在mac上怎么下载

[复制链接]

2万

主题

0

回帖

7万

积分

超级版主

积分
73539
发表于 2024-9-3 22:45:46 | 显示全部楼层 |阅读模式
这篇文章主要介绍了macpython下载安装教程,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。Mac安装Python2、Python3。零、基础准备官网https://www.python.org/下载入口https://www.python.org/downloads/https://www.python.org/downloads/macos/一、安装包下载及安装安装包下载的页面路径是:官网>>>Downloads>>>macOS其他平台根据请自己的实际情况选择安装包下载的页面路径也可以是:官网>>>Downloads(点击)进入到版本选择页面最上面是最新的Release版本,分别是2.x的最新版本和3.x的最新版python怎么画拱形。可以下载最新的Release版本进行安装,也可以通过搜索选择自己想要的版本进行安装。通过搜索找到「2.7.16」通过搜索找到「3.9.9」强烈推荐下载最新的Release版进行安装点击对应的链接分别下载即可(下载的过程中注意操作系统的架构和位数)。👆下载「2.7.18」👆下载「3.10.6」👆下载好的安装包使用下载好的安装包一直「下一步」即可安装对应版本的python。二、安装确认1、Python2查看版本号$python-VPython2.7.18帮助命令$python-husage:/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python[option]...[-ccmd|-mmod|file|-][arg]...Optionsandarguments(andcorrespondingenvironmentvariables):-b:issuewarningsaboutcomparingbytearraywithunicode(-bb:issueerrors)-B:don'twrite.py[co]filesonimport;alsoPYTHONDONTWRITEBYTECODE=x-ccmd:programpassedinasstring(terminatesoptionlist)-d:debugoutputfromparser;alsoPYTHONDEBUG=x-E:ignorePYTHON*environmentvariables(suchasPYTHONPATH)-h:printthishelpmessageandexit(also--help)-i:inspectinteractivelyafterrunning;forcesapromptevenifstdindoesnotappeartobeaterminal;alsoPYTHONINSPECT=x-mmod:runlibrarymoduleasa(terminatesoptionlist)-Optimizegeneratedbytecodeslightly;alsoPYTHONOPTIMIZE=x-OO:removedoc-stringsinadditiontothe-Ooptimizations-R:useapseudo-randomsalttomakehash()valuesofvarioustypesbeunpredictablebetweenseparateinvocationsoftheinterpreter,asadefenseagainstdenial-of-serviceattacks-Qarg:divisionoptions:-Qold(default),-Qwarn,-Qwarnall,-Qnew-s:don'taddusersitedirectorytosys.path;alsoPYTHONNOUSERSITE-S:don'timply'importsite'oninitialization-t:issuewarningsaboutinconsistenttabusage(-tt:issueerrors)-u:unbufferedbinarystdoutandstderr;alsoPYTHONUNBUFFERED=xseemanpagefordetailsoninternalbufferingrelatingto'-u'-v:verbose(traceimportstatements);alsoPYTHONVERBOSE=xcanbesuppliedmultipletimestoincreaseverbosity-V:printthePythonversionnumberandexit(also--version)-Warg:warningcontrol;argisaction:message:category:module:linenoalsoPYTHONWARNINGS=arg-x:skipfirstlineofsource,allowinguseofnon-Unixformsof#!cmd-3:warnaboutPython3.xincompatibilitiesthat2to3cannottriviallyfixfile:programreadfromfile-:programreadfromstdin(default;interactivemodeifatty)arg...:argumentspassedtoprograminsys.argv[1:]OtherenvironmentvariablesYTHONSTARTUP:fileexecutedoninteractivestartup(nodefault)PYTHONPATH:':'-separatedlistofdirectoriesprefixedtothedefaultmodulesearchpath.Theresultissys.path.PYTHONHOME:alternatedirectory(or.Thedefaultmodulesearchpathuses/pythonX.X.PYTHONCASEOK:ignorecasein'import'statements(Windows).PYTHONIOENCODING:Encoding[:errors]usedforstdin/stdout/stderr.PYTHONHASHSEED:ifthisvariableissetto'random',theeffectisthesameasspecifyingthe-Roption:arandomvalueisusedtoseedthehashesofstr,bytesanddatetimeobjects.Itcanalsobesettoanintegerintherange[0,4294967295]togethashvalueswithapredictableseed.2、Python3查看版本号$python3-VPython3.10.6帮助命令$python3-husage:/Library/Frameworks/Python.framework/Versions/3.10/bin/python3[option]...[-ccmd|-mmod|file|-][arg]...Optionsandarguments(andcorrespondingenvironmentvariables):-b:issuewarningsaboutstr(bytes_instance),str(bytearray_instance)andcomparingbytes/bytearraywithstr.(-bb:issueerrors)-B:don'twrite.pycfilesonimport;alsoPYTHONDONTWRITEBYTECODE=x-ccmd:programpassedinasstring(terminatesoptionlist)-d:turnonparserdebuggingoutput(forexpertsonly,onlyworksondebugbuilds);alsoPYTHONDEBUG=x-E:ignorePYTHON*environmentvariables(suchasPYTHONPATH)-h:printthishelpmessageandexit(also-?or--help)-i:inspectinteractivelyafterrunning;forcesapromptevenifstdindoesnotappeartobeaterminal;alsoPYTHONINSPECT=x-I:isolatePythonfromtheuser'senvironment(implies-Eand-s)-mmod:runlibrarymoduleasa(terminatesoptionlist)-O:removeassertand__debug__-dependentstatements;add.opt-1before.pycextension;alsoPYTHONOPTIMIZE=x-OO:do-Ochangesandalsodiscarddocstrings;add.opt-2before.pycextension-q:don'tprintversionandcopyrightmessagesoninteractivestartup-s:don'taddusersitedirectorytosys.path;alsoPYTHONNOUSERSITE-S:don'timply'importsite'oninitialization-u:forcethestdoutandstderrstreamstobeunbuffered;thisoptionhasnoeffectonstdin;alsoPYTHONUNBUFFERED=x-v:verbose(traceimportstatements);alsoPYTHONVERBOSE=xcanbesuppliedmultipletimestoincreaseverbosity-V:printthePythonversionnumberandexit(also--version)whengiventwice,printmoreinformationaboutthebuild-Warg:warningcontrol;argisaction:message:category:module:linenoalsoPYTHONWARNINGS=arg-x:skipfirstlineofsource,allowinguseofnon-Unixformsof#!cmd-Xopt:setimplementation-specificoption.Thefollowingoptionsareavailable:-Xfaulthandler:enablefaulthandler-Xshowrefcountutputthetotalreferencecountandnumberofusedmemoryblockswhentheprogramfinishesoraftereachstatementintheinteractiveinterpreter.Thisonlyworksondebugbuilds-Xtracemalloc:starttracingPythonmemoryallocationsusingthetracemallocmodule.Bydefault,onlythemostrecentframeisstoredinatracebackofatrace.Use-Xtracemalloc=NFRAMEtostarttracingwithatracebacklimitofNFRAMEframes-Ximporttime:showhowlongeachimporttakes.Itshowsmodulename,cumulativetime(includingnestedimports)andselftime(excludingnestedimports).Notethatitsoutputmaybebrokeninmulti-threadedapplication.Typicalusageispython3-Ximporttime-c'importasyncio'-Xdev:enableCPython's"developmentmode",introducingadditionalruntimecheckswhicharetooexpensivetobeenabledbydefault.Effectofthedevelopermode:*Adddefaultwarningfilter,as-Wdefault*Installdebughooksonmemoryallocators:seethePyMem_SetupDebugHooks()Cfunction*EnablethefaulthandlermoduletodumpthePythontracebackonacrash*Enableasynciodebugmode*Setthedev_modeattributeofsys.flagstoTrue*io.IOBasedestructorlogsclose()exceptions-Xutf8:enableUTF-8modeforoperatingsysteminterfaces,overridingthedefaultlocale-awaremode.-Xutf8=0explicitlydisablesUTF-8mode(evenwhenitwouldotherwiseactivateautomatically)-Xpycache_prefix=PATH:enablewriting.pycfilestoaparalleltreerootedatthegivendirectoryinsteadoftothecodetree-Xwarn_default_encoding:enableopt-inEncodingWarningfor'encoding=None'--check-hash-based-pycsalways|default|never:controlhowPythoninvalidateshash-based.pycfilesfile:programreadfromfile-:programreadfromstdin(default;interactivemodeifatty)arg...:argumentspassedtoprograminsys.argv[1:]OtherenvironmentvariablesYTHONSTARTUP:fileexecutedoninteractivestartup(nodefault)PYTHONPATH:':'-separatedlistofdirectoriesprefixedtothedefaultmodulesearchpath.Theresultissys.path.PYTHONHOME:alternatedirectory(or.Thedefaultmodulesearchpathuses/lib/pythonX.X.PYTHONPLATLIBDIRverridesys.platlibdir.PYTHONCASEOK:ignorecasein'import'statements(Windows).PYTHONUTF8:ifsetto1,enabletheUTF-8mode.PYTHONIOENCODING:Encoding[:errors]usedforstdin/stdout/stderr.PYTHONFAULTHANDLER:dumpthePythontracebackonfatalerrors.PYTHONHASHSEED:ifthisvariableissetto'random',arandomvalueisusedtoseedthehashesofstrandbytesobjects.Itcanalsobesettoanintegerintherange[0,4294967295]togethashvalueswithapredictableseed.PYTHONMALLOC:setthePythonmemoryallocatorsand/orinstalldebughooksonPythonmemoryallocators.UsePYTHONMALLOC=debugtoinstalldebughooks.PYTHONCOERCECLOCALE:ifthisvariableissetto0,itdisablesthelocalecoercionbehavior.UsePYTHONCOERCECLOCALE=warntorequestdisplayoflocalecoercionandlocalecompatibilitywarningsonstderr.PYTHONBREAKPOINT:ifthisvariableissetto0,itdisablesthedefaultdebugger.Itcanbesettothecallableofyourdebuggerofchoice.PYTHONDEVMODE:enablethedevelopmentmode.PYTHONPYCACHEPREFIX:rootdirectoryforbytecodecache(pyc)files.PYTHONWARNDEFAULTENCODING:enableopt-inEncodingWarningfor'encoding=None'.三、其他除了使用python、python3命令来调用对应版本的python外,还可以使用如下的命令来调用对应版本的python。$python2-VPython2.7.18$python2.7-VPython2.7.18$python3.10-VPython3.10.6这些都可以可以在/usr/local/bin这个目录下看到相关命令对应的「软连接」。$pwd/usr/local/bin$ls-l|greppythonpython->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonpython-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python-configpython2->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2python2-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2-configpython2.7->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7python2.7-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-configpython3->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3python3-config->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3-configpython3-intel64->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3-intel64python3.10->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10python3.10-config->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10-configpython3.10-intel64->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10-intel64pythonw->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonwpythonw2->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2pythonw2.7->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7PS:python2和python3的兼容性一直被广大开发者诟病。文章知识点与官方知识档案匹配,可进一步学习相关知识Python入门技能树人工智能机器学习工具包Scikit-learn443985人正在系统学习中,Mac安装Python2、Python3。零、基础准备官网https://www.python.org/下载入口https://www.python.org/downloads/https://www.python.org/downloads/macos/一、安装包下载及安装安装包下载的页面路径是:官网>>>Downloads>>>macOS其他平台根据请自己的实际情况选择安装包下载的页面路径也可以是:官网>>>Downloads(点击)进入到版本选择页面最上面是最新的Release版本,分别是2.x的最新版本和3.x的最新版python怎么画拱形。可以下载最新的Release版本进行安装,也可以通过搜索选择自己想要的版本进行安装。通过搜索找到「2.7.16」通过搜索找到「3.9.9」强烈推荐下载最新的Release版进行安装点击对应的链接分别下载即可(下载的过程中注意操作系统的架构和位数)。👆下载「2.7.18」👆下载「3.10.6」👆下载好的安装包使用下载好的安装包一直「下一步」即可安装对应版本的python。二、安装确认1、Python2查看版本号$python-VPython2.7.18帮助命令$python-husage:/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python[option]...[-ccmd|-mmod|file|-][arg]...Optionsandarguments(andcorrespondingenvironmentvariables):-b:issuewarningsaboutcomparingbytearraywithunicode(-bb:issueerrors)-B:don'twrite.py[co]filesonimport;alsoPYTHONDONTWRITEBYTECODE=x-ccmd:programpassedinasstring(terminatesoptionlist)-d:debugoutputfromparser;alsoPYTHONDEBUG=x-E:ignorePYTHON*environmentvariables(suchasPYTHONPATH)-h:printthishelpmessageandexit(also--help)-i:inspectinteractivelyafterrunning;forcesapromptevenifstdindoesnotappeartobeaterminal;alsoPYTHONINSPECT=x-mmod:runlibrarymoduleasa(terminatesoptionlist)-Optimizegeneratedbytecodeslightly;alsoPYTHONOPTIMIZE=x-OO:removedoc-stringsinadditiontothe-Ooptimizations-R:useapseudo-randomsalttomakehash()valuesofvarioustypesbeunpredictablebetweenseparateinvocationsoftheinterpreter,asadefenseagainstdenial-of-serviceattacks-Qarg:divisionoptions:-Qold(default),-Qwarn,-Qwarnall,-Qnew-s:don'taddusersitedirectorytosys.path;alsoPYTHONNOUSERSITE-S:don'timply'importsite'oninitialization-t:issuewarningsaboutinconsistenttabusage(-tt:issueerrors)-u:unbufferedbinarystdoutandstderr;alsoPYTHONUNBUFFERED=xseemanpagefordetailsoninternalbufferingrelatingto'-u'-v:verbose(traceimportstatements);alsoPYTHONVERBOSE=xcanbesuppliedmultipletimestoincreaseverbosity-V:printthePythonversionnumberandexit(also--version)-Warg:warningcontrol;argisaction:message:category:module:linenoalsoPYTHONWARNINGS=arg-x:skipfirstlineofsource,allowinguseofnon-Unixformsof#!cmd-3:warnaboutPython3.xincompatibilitiesthat2to3cannottriviallyfixfile:programreadfromfile-:programreadfromstdin(default;interactivemodeifatty)arg...:argumentspassedtoprograminsys.argv[1:]OtherenvironmentvariablesYTHONSTARTUP:fileexecutedoninteractivestartup(nodefault)PYTHONPATH:':'-separatedlistofdirectoriesprefixedtothedefaultmodulesearchpath.Theresultissys.path.PYTHONHOME:alternatedirectory(or.Thedefaultmodulesearchpathuses/pythonX.X.PYTHONCASEOK:ignorecasein'import'statements(Windows).PYTHONIOENCODING:Encoding[:errors]usedforstdin/stdout/stderr.PYTHONHASHSEED:ifthisvariableissetto'random',theeffectisthesameasspecifyingthe-Roption:arandomvalueisusedtoseedthehashesofstr,bytesanddatetimeobjects.Itcanalsobesettoanintegerintherange[0,4294967295]togethashvalueswithapredictableseed.2、Python3查看版本号$python3-VPython3.10.6帮助命令$python3-husage:/Library/Frameworks/Python.framework/Versions/3.10/bin/python3[option]...[-ccmd|-mmod|file|-][arg]...Optionsandarguments(andcorrespondingenvironmentvariables):-b:issuewarningsaboutstr(bytes_instance),str(bytearray_instance)andcomparingbytes/bytearraywithstr.(-bb:issueerrors)-B:don'twrite.pycfilesonimport;alsoPYTHONDONTWRITEBYTECODE=x-ccmd:programpassedinasstring(terminatesoptionlist)-d:turnonparserdebuggingoutput(forexpertsonly,onlyworksondebugbuilds);alsoPYTHONDEBUG=x-E:ignorePYTHON*environmentvariables(suchasPYTHONPATH)-h:printthishelpmessageandexit(also-?or--help)-i:inspectinteractivelyafterrunning;forcesapromptevenifstdindoesnotappeartobeaterminal;alsoPYTHONINSPECT=x-I:isolatePythonfromtheuser'senvironment(implies-Eand-s)-mmod:runlibrarymoduleasa(terminatesoptionlist)-O:removeassertand__debug__-dependentstatements;add.opt-1before.pycextension;alsoPYTHONOPTIMIZE=x-OO:do-Ochangesandalsodiscarddocstrings;add.opt-2before.pycextension-q:don'tprintversionandcopyrightmessagesoninteractivestartup-s:don'taddusersitedirectorytosys.path;alsoPYTHONNOUSERSITE-S:don'timply'importsite'oninitialization-u:forcethestdoutandstderrstreamstobeunbuffered;thisoptionhasnoeffectonstdin;alsoPYTHONUNBUFFERED=x-v:verbose(traceimportstatements);alsoPYTHONVERBOSE=xcanbesuppliedmultipletimestoincreaseverbosity-V:printthePythonversionnumberandexit(also--version)whengiventwice,printmoreinformationaboutthebuild-Warg:warningcontrol;argisaction:message:category:module:linenoalsoPYTHONWARNINGS=arg-x:skipfirstlineofsource,allowinguseofnon-Unixformsof#!cmd-Xopt:setimplementation-specificoption.Thefollowingoptionsareavailable:-Xfaulthandler:enablefaulthandler-Xshowrefcountutputthetotalreferencecountandnumberofusedmemoryblockswhentheprogramfinishesoraftereachstatementintheinteractiveinterpreter.Thisonlyworksondebugbuilds-Xtracemalloc:starttracingPythonmemoryallocationsusingthetracemallocmodule.Bydefault,onlythemostrecentframeisstoredinatracebackofatrace.Use-Xtracemalloc=NFRAMEtostarttracingwithatracebacklimitofNFRAMEframes-Ximporttime:showhowlongeachimporttakes.Itshowsmodulename,cumulativetime(includingnestedimports)andselftime(excludingnestedimports).Notethatitsoutputmaybebrokeninmulti-threadedapplication.Typicalusageispython3-Ximporttime-c'importasyncio'-Xdev:enableCPython's"developmentmode",introducingadditionalruntimecheckswhicharetooexpensivetobeenabledbydefault.Effectofthedevelopermode:*Adddefaultwarningfilter,as-Wdefault*Installdebughooksonmemoryallocators:seethePyMem_SetupDebugHooks()Cfunction*EnablethefaulthandlermoduletodumpthePythontracebackonacrash*Enableasynciodebugmode*Setthedev_modeattributeofsys.flagstoTrue*io.IOBasedestructorlogsclose()exceptions-Xutf8:enableUTF-8modeforoperatingsysteminterfaces,overridingthedefaultlocale-awaremode.-Xutf8=0explicitlydisablesUTF-8mode(evenwhenitwouldotherwiseactivateautomatically)-Xpycache_prefix=PATH:enablewriting.pycfilestoaparalleltreerootedatthegivendirectoryinsteadoftothecodetree-Xwarn_default_encoding:enableopt-inEncodingWarningfor'encoding=None'--check-hash-based-pycsalways|default|never:controlhowPythoninvalidateshash-based.pycfilesfile:programreadfromfile-:programreadfromstdin(default;interactivemodeifatty)arg...:argumentspassedtoprograminsys.argv[1:]OtherenvironmentvariablesYTHONSTARTUP:fileexecutedoninteractivestartup(nodefault)PYTHONPATH:':'-separatedlistofdirectoriesprefixedtothedefaultmodulesearchpath.Theresultissys.path.PYTHONHOME:alternatedirectory(or.Thedefaultmodulesearchpathuses/lib/pythonX.X.PYTHONPLATLIBDIRverridesys.platlibdir.PYTHONCASEOK:ignorecasein'import'statements(Windows).PYTHONUTF8:ifsetto1,enabletheUTF-8mode.PYTHONIOENCODING:Encoding[:errors]usedforstdin/stdout/stderr.PYTHONFAULTHANDLER:dumpthePythontracebackonfatalerrors.PYTHONHASHSEED:ifthisvariableissetto'random',arandomvalueisusedtoseedthehashesofstrandbytesobjects.Itcanalsobesettoanintegerintherange[0,4294967295]togethashvalueswithapredictableseed.PYTHONMALLOC:setthePythonmemoryallocatorsand/orinstalldebughooksonPythonmemoryallocators.UsePYTHONMALLOC=debugtoinstalldebughooks.PYTHONCOERCECLOCALE:ifthisvariableissetto0,itdisablesthelocalecoercionbehavior.UsePYTHONCOERCECLOCALE=warntorequestdisplayoflocalecoercionandlocalecompatibilitywarningsonstderr.PYTHONBREAKPOINT:ifthisvariableissetto0,itdisablesthedefaultdebugger.Itcanbesettothecallableofyourdebuggerofchoice.PYTHONDEVMODE:enablethedevelopmentmode.PYTHONPYCACHEPREFIX:rootdirectoryforbytecodecache(pyc)files.PYTHONWARNDEFAULTENCODING:enableopt-inEncodingWarningfor'encoding=None'.三、其他除了使用python、python3命令来调用对应版本的python外,还可以使用如下的命令来调用对应版本的python。$python2-VPython2.7.18$python2.7-VPython2.7.18$python3.10-VPython3.10.6这些都可以可以在/usr/local/bin这个目录下看到相关命令对应的「软连接」。$pwd/usr/local/bin$ls-l|greppythonpython->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonpython-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python-configpython2->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2python2-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2-configpython2.7->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7python2.7-config->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-configpython3->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3python3-config->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3-configpython3-intel64->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3-intel64python3.10->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10python3.10-config->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10-configpython3.10-intel64->../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10-intel64pythonw->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonwpythonw2->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2pythonw2.7->../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7PS:python2和python3的兼容性一直被广大开发者诟病。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

QQ|手机版|心飞设计-版权所有:微度网络信息技术服务中心 ( 鲁ICP备17032091号-12 )|网站地图

GMT+8, 2025-1-13 07:25 , Processed in 1.114063 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表