在指示MacPorts切换到Python3.4之后,python --version仍然输出2.7.10。请注意,“哪个python”显示/opt/local/bin在我的路径/usr/bin/前面:
$ which python
/opt/local/bin/python
$ python --version
Python 2.7.10
$ ls -l /opt/local/bin/python
lrwxr-xr-x 1 root wheel 24 Aug 1 10:00 /opt/local/bin/python -> /opt/local/bin/python2.7
$ sudo port select --list python
Available versions for python:
none
python26-apple
python27 (active)
python27-apple
python34
$ sudo port select --set python python34
Selecting 'python34' for 'python' succeeded. 'python34' is now active.
$ which python
/opt/local/bin/python
$ python --version
Python 2.7.10
$ ls -l /opt/local/bin/python
lrwxr-xr-x 1 root wheel 24 Aug 1 10:00 /opt/local/bin/python -> /opt/local/bin/python3.4注意符号链接是如何改变的,但是声明的版本没有改变。怎么回事?
发布于 2017-08-01 21:59:09
tl:运行hash -r。
出于速度上的原因,shell保存了一个缓存,说明当您在shell中键入python时需要运行哪些可执行文件。
考虑没有这样的缓存shell必须做什么:对于输入的每个命令(这不是绝对路径),shell必须执行以下操作:
$PATH中的条目,并对每个条目进行检查stat(2)系统调用,以测试命令是否存在于当前搜索的目录中。请记住,这可能涉及缓慢的旋转磁盘,甚至网络文件系统,回到最初开发shell时。为了加快速度,大多数shell只对每个命令执行一次,直到更改了任何一个$PATH,或者手动告诉shell删除缓存(例如,在bash中使用hash -r,在其他shell中使用rehash )。
不过,对我来说,一些shell也缓存了符号链接,这是个新闻。
https://stackoverflow.com/questions/45432353
复制相似问题