我应该一直使用conda/anaconda(base)吗? [英] With conda/anaconda should I work in (base) all the time?

查看:934
本文介绍了我应该一直使用conda/anaconda(base)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个新手问题,但是我在虚拟环境中安装了conda以及其他一堆东西,例如Tensorflow,现在我有些困惑.如果我打开终端,我的python指向/usr/bin/python.如果我进入基本环境("conda激活基础"),我的路径将指向安装anaconda的位置/usr/local/anaconda2. conda会期望我总是进入基本环境来使用所有anaconda软件包,还是在我的安装中做了一些奇怪的事情,即我的非环境仍然指向原始系统python?我是否应该更改指向水蟒的路径?我正在使用Ubuntu 18.10.

This is a total newbie question, but I installed conda along with a bunch of other stuff like Tensorflow with a virtual environment, and now I'm a little confused. If I open a terminal my python is pointing to /usr/bin/python. If I go to the base environment ("conda activate base"), my path points to where I installed anaconda, /usr/local/anaconda2. Does conda expect that I always go into the base environment to use all the anaconda packages, or did I do something weird on my install that my non-environment still points to the original system python? Should I just change my path to point to anaconda? I'm on Ubuntu 18.10.

推荐答案

我是一个明确的粉丝-而不是在命令行中运行python,而是在运行脚本时使用python解释器的完整路径(例如/usr/local/anaconda2/bin/python)-这样,我不必依赖shell的行为,也不必担心当前哪个环境处于活动状态.使用其完整路径运行解释器与在环境处于活动状态时仅运行python没什么不同.

I am a fan of being explicit -- instead of running python at the command line, I use the full path to the python interpreter when running scripts (e.g. /usr/local/anaconda2/bin/python) -- this way I don't rely on the shell behavior or having to worry about which environment is currently active. Running the interpreter using its full path is no different than just running python while the environment is active.

但是那不是每个人的喝茶...所以...

But that's not everbody's cup of tea... So...

即使anaconda没有提示您更新PATH变量,也可以通过添加PATH=/usr/local/anaconda2/bin${PATH}行来更新.bashrc.bash_profile(或.zshrc或其他任何内容)来显式地进行操作.不要忘记重新获取.bashrc的资源或关闭/重新打开您的shell使其生效.

Even if anaconda did not prompt you to update your PATH variable, you can do it explicitly by updating your .bashrc or .bash_profile (or .zshrc or whatever else) by adding this line: PATH=/usr/local/anaconda2/bin${PATH}. Dont forget to re-source the .bashrc or close/reopen your shell for it to take effect.

Conda可以在基础之外创建许多虚拟环境,因此,如果您有多个虚拟环境,并且想要将其设置为默认环境,则只需更新上面的行以获取适当的路径即可.

Conda is capable of creating many virtual environments beyond the base, so if you have more than one and you want to set one as the default, then just update the line above for the appropriate path.

这篇关于我应该一直使用conda/anaconda(base)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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