简体   繁体   English

当我在终端上调用python时,如何让python2.7成为默认选项?

[英]How to I get python2.7 to be the default option when I call python on terminal?

I recently installed the anaconda package while following a tutorial on data science from the guys at dataquest.io and after my install when I type "python" on the terminal I start Python 3 instead of 2.7. 我最近安装了anaconda软件包,同时遵循dataquest.io上的人员的数据科学教程,在我安装后,当我在终端上键入“python”时,我启动Python 3而不是2.7。

How do I get "python" to open up python 2.7 again? 如何让“python”再次打开python 2.7?

When I type 当我输入

which python

and

which python3

I get the same path : 我得到了同样的道路:

/Users/me/anaconda/bin/ /用户/我/蟒蛇/斌/

Using Mac OS X El Capitan 使用Mac OS X El Capitan

I was playing around with this some time ago and seem to remember that in my PATH variable in Windows (assuming Windows) - the PATH variable will be read such that the first python key is taken as the default. 我前段时间正在玩这个并且似乎记得在我的Windows中的PATH变量中(假设是Windows) - 将读取PATH变量,使得第一个python键被视为默认值。 So in Win 10, I pushed the one I want to the very top of the list and that worked for me. 所以在Win 10中,我将我想要的那个推到列表的最顶端,这对我有用。

Seems has been updated your default anaconda and python folder to python 3. 似乎已将您的默认anaconda和python文件夹更新为python 3。

Easy way is to remove anaconda folder listed and download python 2.7.11 from anaconda and reinstall. 简单的方法是删除列出的anaconda文件夹并从anaconda下载python 2.7.11并重新安装。

In case you have anaconda and anaconda3 in your system than you can update the path according with your needs: export PATH=$HOME/anaconda/bin:$PATH or export PATH=$HOME/anaconda3/bin:$PATH . 如果您的系统中有anaconda和anaconda3,则可以根据需要更新路径:export PATH=$HOME/anaconda/bin:$PATH或export PATH=$HOME/anaconda3/bin:$PATH

Hope it helps. 希望能帮助到你。

You can create a soft link from python to python2.7, namely: 您可以创建从pythonpython2.7,软链接 python2.7,即:

$ pushd /bin && ln -s /bin/python python2.7

$ ls -ls `which python`
1 lrwxrwxrwx 1 Administrator None 13 Feb 25  2016 /bin/python -> python2.7

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

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