Mac配置python环境

Mac配置环境变量不像winsows,没有窗口界面只能通过命令行指令进行配置,下面是Mac配置python环境变量的步骤

1.打开Mac自带终端Terminal;

2、在终端Terminal输入下面的命令:Python3 –version

Mac配置python环境

输入 python –V没反应。但是输入 python3 –V,显示了Python 3.6.8说明,已经安装了python3。看苹果官方,说是内置的python 升级为了python3,python2不再内置了。

3.编辑bash_profile文件

vim .bash_profile

Mac配置python环境

按E进入编辑

Mac配置python环境

 在安i进入插入模式(就可以编辑文件了)

输入Python安装的路径环境变量命令:

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

4、保存退出

先按esc键退出插入模式,再按 : 进入底行模式 再输入 wq 保存退出

5.重新加载配置文件 .bash_profile

输入 source .bash_profile

到此python环境就配好了

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/4736d9d692.html