-
Create environment with preinstalled packages ---------------
$ conda create -n my_env numpy #create my_env, install numpy
$ conda create -n py2 python=2 #create py2, install python ver.=2
$ conda create -n py3 python=3 #create py3, install python ver.=3
$ conda env list
base * /Users/RAYMOND/anaconda3
my_env /Users/RAYMOND/anaconda3/envs/my_env
py2 /Users/RAYMOND/anaconda3/envs/py2
py3 /Users/RAYMOND/anaconda3/envs/py3
/Users/RAYMOND/miniconda3
# Enter environment ---------------
# * indicates which environment we are using
$ source activate py2
(py2) $ conda env list
base /Users/RAYMOND/anaconda3
my_env /Users/RAYMOND/anaconda3/envs/my_env
py2 * /Users/RAYMOND/anaconda3/envs/py2
py3 /Users/RAYMOND/anaconda3/envs/py3
/Users/RAYMOND/miniconda3
(py2) $ python
Python 2.7.14 |Anaconda, Inc.| (default, Mar 27 2018, 12:28:59)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
$ conda env remove -n py3
$ conda env list
base * /Users/RAYMOND/anaconda3
/Users/RAYMOND/miniconda3
進入一個環境後,在開發過程中我們可能會發現有一些套件還需要安裝,可以採用以下的指令管理套件
安裝套件 conda install pkg_name1 pkg_name2 ...
安裝套件指定版本 conda install pkg_name=version_number
移除套件 conda remove pkg_name
更新套件 conda update pkg_name
更新所有套件 conda update -all
列出所有已安裝套件 conda list
清除安裝後下載的原始檔 conda clean -tp
找尋套件 conda search pkg_name
- Install package ---------------
conda install numpy
conda install numpy scipy pandas
- Install package with specific version number ---------------
conda install numpy=1.10
- Remove package ---------------
conda remove package_name
- Update package ---------------
conda update package_name
- Update all package ---------------
conda update --all
- List installed packages ---------------
conda list
- Clean up downloaded library ---------------
$ conda clean -tp
- Search package ---------------
conda search package_name
Others