hrv5

mac自带python2,终端输入python后,显示如下:

linfangdeair:~ linfang$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

然而,如何将mac默认打开python3呢?

***  1. 终端打开.bash_profile文件  ***
open ~/.bash_profile

***  2. .bash_profile文件内容  ***
# 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

# 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

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


***  3. 添加别名->最终文件  ***
alias python="/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

***  4. 终端中重新读取.bash_profile文件  ***
source .bash_profile

再次在终端输入python,结果如下:

linfangdeair:~ linfang$ python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

-------------------------------------------------------------------------------------------------------------------------------------

转载自https://blog.csdn.net/monkey7777/article/details/52295611

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2022-01-15
  • 2021-11-18
  • 2021-11-23
  • 2022-12-23
  • 2021-04-19
猜你喜欢
  • 2022-12-23
  • 2022-02-14
  • 2021-12-05
  • 2022-12-23
  • 2021-04-13
  • 2021-06-27
  • 2021-12-25
相关资源
相似解决方案