在根目录下将默认python更改为anaconda的python [英] Change default python to anaconda's python in root

查看:752
本文介绍了在根目录下将默认python更改为anaconda的python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在系统中安装了python 2.7,并且还安装了Anaconda. 现在,我正在使用python的anaconda,它的工作原理非常完美.不幸的是,我想使用anaconda的python通过root运行.问题是我无法更改root的python路径.

I've installed python 2.7 in my system and I've installed Anaconda also. Right now, I am using python's anaconda and it works perfect. Unfortunately, I wanted to use anaconda's python to be run using root. The issue is that I was unable to change the python path for root.

如果从终端输入"which python",我将得到以下结果:

If I type "which python" from terminal , I am able to get this result:

/home/myuser/anaconda/bin/python

如果我从终端输入"sudo which python",则结果为:

If I type "sudo which python" from terminal, the result is :

/usr/bin/python

我已经将anaconda安装在可由根访问的目录中(在安装过程中已更改),并且已经将其路径添加到/etc/environment(在环境中的PATH中添加了/usr/anaconda/bin).

I have installed anaconda in a directory accessible by root (changed during installation) and I've already added it's path to /etc/environment(added /usr/anaconda/bin to PATH in environment).

如何更改root的默认python路径(我使用sudo命令获取root特权)?

How do I change the default python path of root(I use sudo command to get root privileges)?

我正在使用ubuntu 12.04.

I'm using ubuntu 12.04.

推荐答案

您可以显式调用要运行的python安装:

You can explicitly call the python install you'd like to run:

sudo /opt/anaconda/bin/python

请参见 https://askubuntu.com/questions/477987/两个python-distributions-sudo-picking-wrong-one .

这篇关于在根目录下将默认python更改为anaconda的python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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