的Python腳本不能被卸載找到後刪除舊版本,端口:路徑緩存
sudo port uninstall --follow-dependents python27
但python2.7文件系統路徑:
➜ ~ $ which python2.7
/usr/bin/python2.7
➜ ~ $ python2.7 -V
-bash: /opt/local/bin/python2.7: No such file or directory
➜ ~ $ ll /opt/local/bin/python*
ls: /opt/local/bin/python*: No such file or directory
➜ ~ $ ll /usr/bin/python*
-rwxr-xr-x 2 root wheel 57K 10 12 21:47 /usr/bin/python
-rwxr-xr-x 5 root wheel 925B 10 12 21:47 /usr/bin/python-config
lrwxr-xr-x 1 root wheel 75B 10 12 21:47 /usr/bin/python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x 1 root wheel 82B 10 12 21:47 /usr/bin/python2.5-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x 1 root wheel 75B 10 12 21:47 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82B 10 12 21:47 /usr/bin/python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 70B 10 13 20:38 /usr/bin/python2.7 -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82B 10 12 21:47 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x 2 root wheel 57K 10 12 21:47 /usr/bin/pythonw
lrwxr-xr-x 1 root wheel 76B 10 12 21:47 /usr/bin/pythonw2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x 1 root wheel 76B 10 12 21:47 /usr/bin/pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76B 10 12 21:47 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
➜ ~ $ /usr/bin/python2.7 -V
Python 2.7.5
➜ ~ $ ll /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
-rwxr-xr-x 1 root wheel 34K 10 12 21:47 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
路徑值是:
➜ ~ $ echo $PATH|tr ':' '\n'
/Users/adyliu/.rvm/gems/ruby-2.0.0-p247/bin
/Users/adyliu/.rvm/gems/[email protected]/bin
/Users/adyliu/.rvm/rubies/ruby-2.0.0-p247/bin
/Users/adyliu/.rvm/bin
/opt/local/bin
/opt/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Users/adyliu/bin
我之前使用的端口安裝python2.7.3,所以「的/ opt/local/bin目錄」的路徑前'/ usr/bin'的路徑, 和python腳本(python2.7)在'/ opt/local/bin'之前卸載了這個python。
現在我的問題是爲什麼python腳本無法找到,雖然該文件在系統路徑中。
➜ ~ $ for d in `echo $PATH|tr ':' ' '`;do if [ -x $d/python2.7 ]; then ls -lh $d/python2.7;fi;done
lrwxr-xr-x 1 root wheel 70B 10 13 20:38 /usr/bin/python2.7 -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
➜ ~ $ which python2.7
/usr/bin/python2.7
➜ ~ $ python2.7 -V
-bash: /opt/local/bin/python2.7: No such file or directory
如何刪除命令的哈希緩存:
➜ ~ $ command -V python2.7
python2.7 is hashed (/opt/local/bin/python2.7)
➜ ~ $ type python2.7
python2.7 is hashed (/usr/bin/python2.7)
➜ ~ $ type python
python is hashed (/usr/bin/python)
更新1:
我不知道爲什麼 'python2.7' 可以被發現現在正確(問題發佈後10分鐘)。
➜ ~ $ command -V python2.7
python2.7 is hashed (/usr/bin/python2.7)
更新2:
的 'python2' 腳本還是不能被發現:
➜ ~ $ python2 -V
-bash: /opt/local/bin/python2: No such file or directory
➜ ~ $ python2
-bash: /opt/local/bin/python2: No such file or directory
➜ ~ $ which python2
/usr/bin/python2
➜ ~ $ command -V python2
python2 is hashed (/opt/local/bin/python2)
➜ ~ $ python2 -V
-bash: /opt/local/bin/python2: No such file or directory
➜ ~ $ /usr/bin/python2 -V
Python 2.7.5
➜ ~ $ ll /usr/bin/python2
lrwxr-xr-x 1 root wheel 18B 10 13 20:50 /usr/bin/python2 -> /usr/bin/python2.7
➜ ~ $ python2.7 -V
Python 2.7.5
➜ ~ $ python2 -V
-bash: /opt/local/bin/python2: No such file or directory
我找到這樣的問題:http://unix.stackexchange.com/questions/5609/how-do-i-clear-bashs-cache-of-paths-to-executables – imxylz