echo $PATH给我
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin但是当我想将usr / local / bin的顺序更改到/Library/Frameworks/Python.framework/Versions/3.4/bin的前面时,我键入
sudo emacs /etc/paths只要
/usr/local/bin: /usr/bin: /bin: /usr/sbin: /sbin: 我如何将/usr/local/bin的顺序更改为第一个? 我可以删除不再有用的那些,例如/Library/Frameworks/Python.framework/Versions/3.4/bin ,以及如何? 因为我删除Python.framework? 更改订单后如何保存更改?echo $PATH gives me
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/binbut when I want to change the order of /usr/local/bin to the front of /Library/Frameworks/Python.framework/Versions/3.4/bin, I type
sudo emacs /etc/pathsI only get
/usr/local/bin: /usr/bin: /bin: /usr/sbin: /sbin:How can I insert /usr/local/bin in front of my PATH?
最满意答案
您可以在主目录中的.bash_profile中设置PATH,例如:
emacs ~/.bash_profile然后通过在其中放置适当的export语句将其设置为你想要的:
export PATH=/usr/local/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin更好的解决方案是将append / prepend追加到现有路径中,如下所示:
export PATH=/usr/local/bin:$PATH注意:这不是您可以设置PATH的唯一位置,但它是常见的。
You can set your PATH in the file .bash_profile, which is in your home directory.
More specifically, you can simply add the following line to the end of that file
export PATH=/usr/local/bin:$PATHThis results in /usr/local/bin being prepended to the existing PATH. In other words, the folder /usr/local/bin is inserted in front of your PATH, and so it would have the highest priority. You can also append a folder to your path by doing
export PATH=$PATH:/usr/local/binIn general, you can set the order of the folders or files that you export in a similar way as the following:
export PATH=/usr/local/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/binNote: this is not the only place you can set the PATH, but it is a common one.
更多推荐
发布评论