从终端调用时使用默认 Python 而不是 Anaconda 安装 [英] Use the default Python rather than the Anaconda installation when called from the terminal

查看:24
本文介绍了从终端调用时使用默认 Python 而不是 Anaconda 安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了 Python 的 Anaconda 版本.现在,当我在终端中键入 python 时,它会打开 Anaconda 发行版,而不是默认发行版.如何让它在 Linux 上使用命令 python 的默认版本(Ubuntu 12.04 (Precise Pangolin))?

I recently installed the Anaconda version of Python. Now when I type python into the terminal it opens the Anaconda distribution rather than the default distribution. How do I get it to use the default version for the command python on Linux (Ubuntu 12.04 (Precise Pangolin))?

推荐答案

Anaconda 将路径添加到你的 .bashrc,所以首先找到它.您可以将默认 Python 实例的路径添加到 .bashrc 或删除 Anaconda 的路径(如果您不想使用它).

Anaconda adds the path to your .bashrc, so it is found first. You can add the path to your default Python instance to .bashrc or remove the path to Anaconda if you don't want to use it.

您还可以在 Bash 中使用完整路径 /usr/bin/python 来使用默认的 Python 解释器.

You can also use the full path /usr/bin/python in Bash to use the default Python interpreter.

如果您保持 .bashrc 文件不变,则使用 python 运行的任何命令都将使用 Anaconda 解释器.如果需要,您还可以为每个解释器使用 alias.

If you leave your .bashrc file as is, any command you run using python will use the Anaconda interpreter. If you want, you could also use an alias for each interpreter.

您将在 .bashrc 文件中看到类似 export PATH=$HOME/anaconda/bin:$PATH 的内容.

You will see something like export PATH=$HOME/anaconda/bin:$PATH in your .bashrc file.

所以基本上,如果您想使用 Anaconda 作为您的主要日常解释器,请使用默认 Python 的完整路径或创建 alias.如果您想反过来,请删除 export PATH=....从 bashrc 并使用 Anaconda Python 解释器的完整路径.

So basically, if you want to use Anaconda as your main everyday interpreter, use the full path to your default Python or create an alias. If you want it the other way around, remove the export PATH=.... from bashrc and use full path to Anaconda Python interpreter.

这篇关于从终端调用时使用默认 Python 而不是 Anaconda 安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆