简体   繁体   English

使用Homebrew python代替系统提供的python

[英]Using Homebrew python instead of system provided python

I used Homebrew to install python, the version is 2.7.10, and the system provided version is 2.7.6. 我使用Homebrew安装python,版本为2.7.10,系统提供的版本为2.7.6。 My PATH environment variable is set to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" , so my terminal DOES know to look at the Homebrew bin folder first! 我的PATH环境变量设置为/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" ,因此我的终端机不知道先查看Homebrew bin文件夹!

However, when I run python, it still defaults to 2.7.6, the system provided version (the interpreter that shows up says 2.7.6 at the top). 但是,当我运行python时,它仍默认为2.7.6,即系统提供的版本(显示的解释器顶部为2.7.6)。 If I run /usr/local/bin/python , it runs 2.7.10, which is what I want. 如果我运行/usr/local/bin/python ,它将运行2.7.10,这是我想要的。

If my PATH variable is properly set, then how is it possible that terminal still finds /usr/bin/python first? 如果正确设置了我的PATH变量,那么终端怎么可能仍然先找到/usr/bin/python

This happened to me when I installed Python 2.7.10 using brew. 当我使用brew安装Python 2.7.10时,这发生在我身上。 My PATH was set to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and which python returned /usr/local/bin/python (which is symlinked to Python 2.7.10.) 我的PATH设置为/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin以及哪个python返回/usr/local/bin/python (与Python 2.7.10链接)。

Problem went away when I closed and restarted Terminal application. 当我关闭并重新启动终端应用程序时,问题消失了。

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

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