我需要在macosxlion上去掉/Library/Frameworks/Python.framework/Versions/2.7/bin
变量中的$PATH
。我打开了几个文件,这些文件向路径中添加了一些内容,但找不到添加python路径的位置。以下是几个文件和路径变量的输出:
echo $PATH
返回
/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Users/friedrich/.rvm/gems/ruby-1.9.3-p362/bin:/Users/friedrich/.rvm/gems/ruby-1.9.3-p362@global/bin:/Users/friedrich/.rvm/rubies/ruby-1.9.3-p362/bin:/Users/friedrich/.rvm/bin:/Users/friedrich/.rbenv/shims:/Users/friedrich/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin
文件/etc/paths/
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
文件~/.profile
export PATH=$PATH:/usr/local/git/bin:/usr/local/Cellar/todo-txt/2.9/bin
文件~/.bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# todo.txt script path
source /usr/local/Cellar/todo-txt/2.9/etc/bash_completion.d/todo_completion complete -F _todo t
# MacPorts Installer addition on 2013-03-01_at_21:26:56: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
最后一个向路径添加内容的文件似乎是.bash_profile
正在添加export PATH=/opt/local/bin:/opt/local/sbin:$PATH
,因此我需要该文件在此之前一步添加内容。
考虑到路径添加到
$PATH
变量的顺序(因此您希望删除第三个元素),可以在.bash_profile
的末尾添加这样的命令:还有更多的方法可以在OSX上为您的路径添加内容
除了
/etc/paths
文件之外,还有一个目录/etc/paths.d
。该目录中有与/etc/paths
格式相同的文本文件。/etc/paths.d
中每个文件的行被添加到路径中/etc/paths
中的行之后和.bash_profile
中的内容之前(尽管这完全取决于.bash_profile
中的内容)。如果您不需要的Python框架路径不在上面,我可以考虑尝试另外两个地方。还有
/private/etc/paths
和/private/etc/paths.d
,可能还有一个.bashrc
文件在主目录中。我希望这对你有用。如果没有,那么我将使用的解决方法是生成
.bash_profile
中的最后一个命令,将/usr/bin
附加到路径前面。这样,在Python的框架版本之前就可以找到Apple版本的Python(链接到/usr/bin
)。可以使用参数展开修剪路径的固定部分。将此添加到
.bash_profile
的结尾(或至少延迟到添加有问题的路径后处理):(所有的反斜杠都很不幸,但你至少只需要打一次。)
相关问题 更多 >
编程相关推荐