安装python 3.7.2后,usr / bin只有python 2.7

问题描述 投票:-1回答:1

我是python的新手,我刚刚安装了python 3.7.2,至少这是我的IDLE告诉我的。但是,当我检查我的usr / bin时,我只看到了python2.7。这是为什么?这是怎么回事?

提前致谢!

P.S。:这是我的机器看到的第一个也是唯一一个python,我很确定。

系统:IOS v.10.13.6

python python-2.7 installation python-3.7
1个回答
1
投票

现在有一天,MAC OS X预装了python2,它们可以将它放在/usr/local/bin中使用,这个位置已经在系统路径中了。

如果您安装任何新版本,如Python3 +,它将安装在/Library/Frameworks/Python.framework/Versions/<version>/bin/上。

例如。就我而言,完整路径是/Library/Frameworks/Python.framework/Versions/3.6/bin/python3/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

我使用Homebrew安装了Python3.6。

以下是我的终端的有用日志。请看一看。

»版本检查路径(哪个python)

Rishikeshs-MacBook-Air:~ hygull$ which python
/usr/local/bin/python
Rishikeshs-MacBook-Air:~ hygull$ 

哪个python3

Rishikeshs-MacBook-Air:~ hygull$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Rishikeshs-MacBook-Air:~ hygull$ 

哪个python3.6

Rishikeshs-MacBook-Air:~ hygull$ which python3.6
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Rishikeshs-MacBook-Air:~ hygull$ 

»启动和退出(python2,MAC OS X上的默认安装)

蟒蛇

Rishikeshs-MacBook-Air:~ hygull$ python
Python 2.7.15 (default, Jan 12 2019, 21:07:57) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> exit()
Rishikeshs-MacBook-Air:~ hygull$ 

python3

Rishikeshs-MacBook-Air:~ hygull$ python3
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> exit()
Rishikeshs-MacBook-Air:~ hygull$ 

python3.6

(与上面相同,但是如果你有两个python3 +就很有用,例如你安装了python3.6和python3.7并且你想使用python3.6)

Rishikeshs-MacBook-Air:~ hygull$ python3.6
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
© www.soinside.com 2019 - 2024. All rights reserved.