简体   繁体   English

OS X上的$ PATH异常

[英]Abnormal $PATH on OS X

I realize that this is probably a simple question but, I'm 95% my path is screwed up. 我意识到这可能是一个简单的问题,但是我95%的想法都搞砸了。 The result of opening a new terminal and typing [echo $PATH] is: 打开一个新终端并键入[echo $ PATH]的结果是:

/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/bmoog/.rvm/bin

Looking around it seems that it should be something more like: 环顾四周,看起来应该更像是:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

Any guesses as to why I am going into my Python.framework? 关于为什么要进入Python.framework的任何猜测?

The Python installers from python.org, and from many other sources, do not install anything into /usr/local/bin or /usr/bin. 来自python.org和其他许多来源的Python安装程序不会在/ usr / local / bin或/ usr / bin中安装任何内容。 Instead, they install everything into a bin directory within the framework, and then give you an option to add that bin directory to your path. 相反,他们将所有内容安装到框架内的bin目录中,然后为您提供一个选项,以将该bin目录添加到您的路径中。 (Generally, any script that get installed either with that Python, or with packages you later install into it, also end up in the framework's bin directory.) (通常,随该Python或以后安装的软件包一起安装的任何脚本都将最终出现在框架的bin目录中。)

So, at some point, you ran a third-party Python 2.7 installer, and checked the checkbox/manually ran the post-install script/etc. 因此,在某个时候,您运行了第三方Python 2.7安装程序,并选中了该复选框/手动运行了安装后脚本/ etc。 to do this. 去做这个。

All the option does is prepend the following 4 lines to your ~/.bash_profile : 所有选项所做的就是在您的~/.bash_profile以下4行:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

(Possibly with the typo orginal for original fixed, depending on your version.) (可能与错字orginaloriginal固定,这取决于您的版本。)

So, you can revert by just cp ~/.bash_profile.pysave ~/.bash_profile if you're not afraid of losing any subsequent changes… or, more safely, just edit the file in your favorite text editor and remove those lines. 因此,如果您不担心丢失任何后续更改,则可以仅通过cp ~/.bash_profile.pysave ~/.bash_profile进行还原…或者,更安全地,只需在您喜欢的文本编辑器中编辑文件并删除这些行即可。


Of course if you do this, you will no longer be able to run that third-party Python, or its 2to3 , or an ipython you installed for it, etc., without specifying a horrible absolute path… 当然,如果您这样做,则将无法运行该第三方Python或其2to3ipython安装的ipython等,而无需指定可怕的绝对路径…


Meanwhile, you probably didn't need a third-party Python 2.7 in the first place. 同时,您可能首先不需要第三方Python 2.7。 Apple has been providing Python 2.7 for at least three major OS versions now (2.7.5 in Mavericks, 2.7.2 in Lion and Mountain Lion), as /usr/bin/python . 苹果现在已经为至少三个主要的操作系统版本(Mavericks中的2.7.5,Lion和Mountain Lion中的2.7.2)提供了Python 2.7,作为/usr/bin/python If you don't want this 2.7 on your PATH, you probably don't want it at all, so I'd just uninstall it. 如果您不想在PATH上使用此2.7,则可能根本不想要它,因此我将其卸载。

Check your ~/.bash_profile and then all the files it includes to see where the extra path is coming from. 检查您的~/.bash_profile ,然后检查其中包含的所有文件,以查看额外路径来自何处。 Somewhere there will be a line like: 在某处会有一条线:

export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}

But do you really care? 但是你真的在乎吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM