conda环境可以访问“根"环境吗? (==系统软件包)? [英] Do conda environments have access to 'root' environment? (== system packages)?

查看:86
本文介绍了conda环境可以访问“根"环境吗? (==系统软件包)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

conda中的根"环境是什么?仅仅是使用(仅)系统软件包的环境吗?

What is the 'root' environment in conda? Is it just an environment which uses (only) the system packages?

其他环境是否也使用系统软件包(我假设优先考虑其重复版本)?

Do other environments use the system packages as well (I would assume giving preference to their versions of duplicates)?

还是我需要在要使用它们的环境中安装所有软件包?

Or would I need to install all of my packages in the environment where I want to use them?

是否可以将其配置为选项?

Is there a way of configuring this as an option?

我已经安装了系统软件包,但是在conda环境中无法导入它.

I have a system package installed but I can't import it when I'm in a conda environment.

推荐答案

根环境只是您在其中启动的环境.您只能访问已明确安装在当前conda环境中的python软件包.这是我的系统的外观.请注意,python模块搜索列表(sys.path)中的所有路径都在conda根文件夹中:

The root environment is just the environment you start in. You only have access to python packages that you've explicitly installed in the current conda environment. Here is what my system looks like. Note that all the paths in the python module search list (sys.path) are in the root conda folder:

jmepple-lm:~ jmeppley$ conda env list
# conda environments:
#
anvio                    /Users/jmeppley/anaconda3/envs/anvio
anvio2                   /Users/jmeppley/anaconda3/envs/anvio2
jupyter                  /Users/jmeppley/anaconda3/envs/jupyter
snake                    /Users/jmeppley/anaconda3/envs/snake
root                  *  /Users/jmeppley/anaconda3

jmepple-lm:~ jmeppley$ python -c "import sys; print(\"\\n\".join(sys.path))"

/Users/jmeppley/anaconda3/lib/python35.zip
/Users/jmeppley/anaconda3/lib/python3.5
/Users/jmeppley/anaconda3/lib/python3.5/plat-darwin
/Users/jmeppley/anaconda3/lib/python3.5/lib-dynload
/Users/jmeppley/anaconda3/lib/python3.5/site-packages
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/aeosa
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/galaxy_lib-17.5.9-py3.5.egg
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/mmtf_python-1.0.5-py3.5.egg
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/pysftp-0.2.8-py3.5.egg
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/python_dateutil-2.3-py3.5.egg
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg
/Users/jmeppley/anaconda3/lib/python3.5/site-packages/urllib3-1.12-py3.5.egg

当您切换conda环境时,python现在将从特定于该环境的文件夹中提取python模块:

When you switch conda environments, python will now pull python modules from folders specific to that environment:

jmepple-lm:~ jmeppley$ source activate snake
(snake) jmepple-lm:~ jmeppley$ python -c "import sys; print(\"\\n\".join(sys.path))"

/Users/jmeppley/anaconda3/envs/snake/lib/python35.zip
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/plat-darwin
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/lib-dynload
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages/mmtf_python-1.0.5-py3.5.egg
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages/pysftp-0.2.8-py3.5.egg
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages/python_dateutil-2.3-py3.5.egg
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg
/Users/jmeppley/anaconda3/envs/snake/lib/python3.5/site-packages/urllib3-1.12-py3.5.egg

如果要访问python模块,则必须使用conda install XXX(推荐)或pip install XXX在该conda环境中显式安装它.

If you want access to a python module, you'll have to instal it explicitly in that conda environment with conda install XXX (recommended) or pip install XXX.

据我所知,没有简单的方法可以覆盖此行为.

As far as I know, there is no easy way to override this behavior.

注意:对于非python程序,情况并非如此.执行路径中的任何程序将始终可用,并且优先通过conda安装的程序.这是因为conda安装位置位于PATH的开头. EG:

NOTE: This is not true for non-python programs. Any programs in your execution path will always be available, with preference given to programs installed via conda. This is because the conda install location is at the start of your PATH. EG:

(snake) jmepple-lm:~ jmeppley$ echo $PATH
/Users/jmeppley/anaconda3/envs/snake/bin:/Users/jmeppley/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

这篇关于conda环境可以访问“根"环境吗? (==系统软件包)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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