Python基础知识Python基础

Mac终端默认打开python3

2019-07-02  本文已影响2人  HuyaRC

Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。

Mac自带python2,终端输入pythonpython --versionpython -V即可查看版本

Python3 最新源码:
Python 官网:https://www.python.org/
Python文档下载地址:https://www.python.org/doc/

先看下Python安装地址:
which python
输出:/usr/bin/python
注意:这是python2 的命令地址

  1. python 3的命令地址:
    which python3
    输出:
    /Library/Frameworks/Python.framework/Versions/3.7/bin/python3

  2. 终端打开.bash_profile文件
    ![4DA9D289-496D-4BB1-B0DD-4331E7D62109.png](https://img.haomeiwen.com/i2675141/6ce31f64ed3e39cc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

    .bash_profile文件.png

3.添加别名:在文件最后添加alisa
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"
变成了:

添加alisa.png

command+s保存

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

最后,在终端中输入python

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
上一篇下一篇

猜你喜欢

热点阅读