简体   繁体   English

设置默认的python版本

[英]Set default python version

After installing Anaconda , when I run python sometimes I load the one provided with Anaconda, and others the one I installed with brew. 安装Anaconda后 ,当我运行python时,有时会加载Anaconda提供的一个,而其他人则是通过brew安装的。 Both versions are 2.7.6 , but I get a Segmentation fault: 11 error, which is probably due to the fact that there are now two options. 这两个版本都是2.7.6 ,但是我遇到了Segmentation fault: 11错误,这可能是由于现在有两个选项。 Is there a way to fix this? 有没有办法解决这个问题?

The usual fix for problems like this one is to make sure the version you want is first in the search path of your shell (or the other version isn't in the path - but that's sometimes impossible). 解决此类问题的常用方法是确保所需的版本位于外壳程序的搜索路径中的首位(或者其他版本不在路径中-但这有时是不可能的)。

With Unix-like systems, check the value of the $PATH variable. 对于类Unix系统,请检查$PATH变量的值。

[EDIT] See this document for the general concept of wrapper scripts . [编辑]有关包装脚本的一般概念,请参见此 文档

Create such a script with this content: 使用以下内容创建这样的脚本:

#!/bin/sh
PATH="/Users/Alberto/anaconda/bi‌​n:$PATH"
export PATH
exec anaconda

This assumes that the Python which you want to use is in the folder /Users/Alberto/anaconda/bi‌​n and that the program which you want to wrap is called anaconda . 这假设您要使用的Python在/Users/Alberto/anaconda/bi‌​n文件夹中,并且您要包装的程序称为anaconda

Make this script executable. 使此脚本可执行。 After that, you can start the application using the wrapper script and it should always work. 之后,您可以使用包装器脚本启动应用程序,并且该应用程序应始终运行。

Note: Platypus might make it easier to use the script. 注意: 鸭嘴兽可能会使使用脚本更容易。

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

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