ITPub博客

首页 > IT职业 > IT图书 > mac上如何安装python3

mac上如何安装python3

IT图书 作者:wjaning 时间:2021-09-11 10:32:47 0 删除 编辑


mac上如何安装python3?

·安装homebrew

在终端执行命令

/usr/bin/ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"

执行完成后,homebrew和pip等工具就自动安装好了。

相关推荐:《Python教程》

·接下来安装python3.在终端执行命令:

brew install python

执行完成后可以在的系统目录:/usr/local/Cellar/python中看到python的安装版本。

注意:在 /usr/bin/ 目录中的python是系统预装的python

此时,如果你希望在终端中输入 python 直接使用的是你新安装的python3。那么需要配置一下环境变量,指定一下python只用版本就行了。

·配置如下:

export PATH=${PATH}:/usr/local/Cellar/python/3.7.3/bin
alias python="/usr/local/Cellar/python/3.7.3/bin/python3"
alias pip="/usr/local/Cellar/python/3.7.3/bin/pip3"

推荐看原文:http://tryenough.com/python_install

解释一下:

第一行指定python3全局环境变量
第二行为python命令重命名
第三行为pip命令重命名

此时就安装好并配置好了python3。

mac上使用python推荐阅读:

怎么在mac上使用python

mac怎么执行python文件?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2983/viewspace-2836497/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-06

  • 博文量
    73
  • 访问量
    6472