Mac OS X:brew 报告 python 3.7.3,python3 --version 报告 python 3.6.3。如何修复?

Mac OS X:brew 报告 python 3.7.3,python3 --version 报告 python 3.6.3。如何修复?

我正在运行 Mac OS X High Sierra 10.13.6。

当我从终端执行“brew list python”时,它显示我已经安装了 python 3.7.3:

user@laptop:~$ brew list python
/usr/local/Cellar/python/3.7.3/bin/2to3
/usr/local/Cellar/python/3.7.3/bin/2to3-3.7
/usr/local/Cellar/python/3.7.3/bin/easy_install-3.7
/usr/local/Cellar/python/3.7.3/bin/idle3
/usr/local/Cellar/python/3.7.3/bin/idle3.7
/usr/local/Cellar/python/3.7.3/bin/pip3
/usr/local/Cellar/python/3.7.3/bin/pip3.7
/usr/local/Cellar/python/3.7.3/bin/pydoc3
/usr/local/Cellar/python/3.7.3/bin/pydoc3.7
/usr/local/Cellar/python/3.7.3/bin/python3
/usr/local/Cellar/python/3.7.3/bin/python3-config
/usr/local/Cellar/python/3.7.3/bin/python3.7
/usr/local/Cellar/python/3.7.3/bin/python3.7-config
/usr/local/Cellar/python/3.7.3/bin/python3.7m
/usr/local/Cellar/python/3.7.3/bin/python3.7m-config
/usr/local/Cellar/python/3.7.3/bin/pyvenv
/usr/local/Cellar/python/3.7.3/bin/pyvenv-3.7
/usr/local/Cellar/python/3.7.3/bin/wheel3
/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/ (2818 files)
/usr/local/Cellar/python/3.7.3/IDLE 3.app/Contents/ (8 files)
/usr/local/Cellar/python/3.7.3/lib/pkgconfig/ (3 files)
/usr/local/Cellar/python/3.7.3/libexec/bin/ (7 files)
/usr/local/Cellar/python/3.7.3/libexec/pip/ (701 files)
/usr/local/Cellar/python/3.7.3/libexec/setuptools/ (345 files)
/usr/local/Cellar/python/3.7.3/libexec/wheel/ (38 files)
/usr/local/Cellar/python/3.7.3/Python Launcher 3.app/Contents/ (16 files)
/usr/local/Cellar/python/3.7.3/share/man/ (2 files)
user@laptop:~$ 

... but when I do a "python3 --version", it reports Python 3.6.3:

user@laptop:~$ python3 --version
Python 3.6.3
user@laptop:~$ 

“which python3”报告:

user@laptop:~$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
user@laptop:~$

我在该目录中没有看到任何 3.7 Python 版本:

user@laptop:/Library/Frameworks/Python.framework/Versions$ ls -alt
total 0
drwxr-xr-x   6 root  wheel   192B Nov 30  2017 ../
drwxrwxr-x  10 root  admin   320B Nov 30  2017 3.6/
drwxrwxr-x   3 root  wheel    96B Oct  3  2017 ./
user@laptop:/Library/Frameworks/Python.framework/Versions$

有一次,我安装了 PyCharm CE。它是一个 IDE,但我不确定它是否可以安装单独的 Python 3.x?

我还安装了 Python 3.6 IDLE。

我希望将我的 Mac 完全恢复为出厂默认设置,但这是一台工作电脑,由我们的公司团队管理,安装了许多应用程序。我估计重新安装和重新做所有事情需要 20 个小时左右,所以很遗憾恢复出厂设置是不可能的。

有人能给我一些关于如何解决这个 Python 问题的指导吗?

答案1

我很确定添加:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

到你的 .bashrc(或 .zshrc 或你正在使用的任何 shell)应该可以完成这项工作(只需记住在进行更改后获取它,或重新启动终端)。

最后,你可能想看看 pyenv - 几个月前我为自己写了一个教程(可用这里

相关内容