2017-01-13 119 views
5

康達的「根」環境是什麼?它只是一個使用(僅)系統軟件包的環境?conda環境能夠訪問「根」環境嗎? (==系統包)?

其他環境是否也使用系統包(我假設優先考慮它們的重複版本)?

或者我需要將我的所有軟件包安裝在我想使用它們的環境中嗎?

有沒有一種方法來配置這個選項?

我安裝了一個系統軟件包,但當我在conda環境中時無法導入它。

+0

conda的名字「根」的選擇環境是可怕的,意味着各種各樣的錯誤的東西,例如,權限,特權升級的風險。如果它簡單地被命名爲「基地」,那麼這個討論將會被消除。 – smci

回答

4

根環境只是您開始使用的環境。您只能訪問在當前conda環境中顯式安裝的python包。這是我的系統的樣子。需要注意的是,在Python模塊搜索列表(sys.path的)所有路徑都在根文件夾暢達:

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 

當您切換暢達的環境中,巨蟒將現在由特定於環境的文件夾拉Python模塊:

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明確安設它在暢達環境。

據我所知,沒有簡單的方法來覆蓋這種行爲。

注意:對於非python程序,這不是真的。執行路徑中的任何程序都將始終可用,並優先考慮通過conda安裝的程序。這是因爲conda安裝位置在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