【发布时间】:2021-11-05 19:40:28
【问题描述】:
我的 mac 默认自带 Python2。我使用 Homebrew (brew install python3) 安装了 Python3,并做了 something 以使 python 指向终端中的 python3。不幸的是,我不记得我做了什么(我一定是随便复制并粘贴了几行命令才能将python 设置为python3)。现在我想找出我做了什么被遗忘了,我在我的 $PATHS、我的 .bash_profile、.zhrc 等中到处寻找但我没有为 python 或 python3 找到任何设置 - 没有写入路径,也没有别名。
这怎么可能?我还能做什么?
我的 Python 版本:
my-mac:~ myname$ python2
Python 2.7.16 (default, Feb 28 2021, 12:34:25)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
my-mac:~ myname$ python
Python 3.9.6 (default, Jun 29 2021, 05:25:02)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
这是我所有的路径:
my-mac:~ myname$ echo "${PATH//:/$'\n'}"
/Users/myname/.rvm/gems/ruby-1.9.3-p327/bin
/Users/myname/.rvm/gems/ruby-1.9.3-p327@global/bin
/Users/myname/.rvm/rubies/ruby-1.9.3-p327/bin
/Users/myname/.rvm/bin
/usr/local/mysql/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/TeX/texbin
/Users/myname/Qt/5.5/clang_64/bin/
检查 Python 和 Python3 路径:
my-mac:~ myname$ type python
python is hashed (/usr/local/bin/python)
my-mac:~ myname$ type python3
python3 is /usr/local/bin/python3
我的 .bash_profile 和 .zshrc 内容:
my-mac:~ myname$ nano .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
my-mac:~ myname$ nano .zshrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
【问题讨论】: