The basic commands of Conda 2020-10-13

The following commands all comes frome the url (the official website of conda):

please click the portal if u want to check the commands of conda from official websit

1.Conda Management

Show the version of conda

conda --version
# or
conda -V

Check more info about Conda

conda info

Updata Conda

conda update conda

2. Manage the virtual enviroment

Show the info of help about conda create

conda create --help

Create vitual enviroment

# envname :the name of the env u want to create
conda create --name envname
#The env u created will be stored in the **location of conda/env**

Delete the vitual env

conda remove -n envname --all

Create the specific version of python of other pacakges

# indicate python version
conda create -n envname python=3.4
# indicate the specific pacakge 
conda create -n envname scipy=0.15.0
# indicate the python version & mutiple pacakges 
conda create -n envname python=3.7 scipy 

Install pacakges for virtual env

conda install -n envname scipy=0.15.0

If you want to install specific pacakges when creating a new env , you can make it by modifying the file .condarc

Clone a env

conda create --name clone_env --clone envname

Show all envs

conda info --envs

Create a same Conda env (not bying clone)

# View the info of packages
conda list --explicit 
# export the info to current catalog
conda list --explicit > spec-file.txt
# use the file to build the same env like former
conda create --name newenv --file spec-file.txt
# use the packages-info-file to install pacakges in a already existed env
conda install --name newenv --file spec-file.txt

Activate a new env

# for windows:
activate envname #use command ' deactivate ' to quit the env
# for Linux & Macos
source activate envname #use command 'source deactivate ' to quit the env

View the pacakges list

conda list
conda list -n envame
conda list -n envname numpy

Use pip

conda install -n envname pip
source activate envname
pip <pip_subcommand>

3. Share ur env

To realize by generate a enviroment.yml file

conda env export > enviroment.yml

u can also write a yml file like below

name: stats
dependencies:
  - numpy
  - pandas
# a more complex version
name:stats2
channels
  - javascript
dependencies:
  - python=3.4
  - flask
  - pip:
    - Flask-Testing

u can also use the method below to exclude default channel

channels:
  - javascript
  - nodefaults

4. 通道管理

# add a new channel *new_channel* to top of the channel list
conda config --add channels new_channel
#or
conda cofig prepend channels new_channel
# add a new channel *new_channel* to bottle of the channel list
conda cofig --append channels new_channel
# Show channel situation
conda config --set show_channel_urls yes

5.卸载Anaconda

1.找到自己安装的目录,删除整个目录

sudo rm -rf username/anaconda3

2.修改配置文件

(1) 修改bash的用户文件

#修改配置文件
vim ~/.bashrc  #如果你的配置文件为个人的
vim /etc/profile  #如果你的配置文件在系统文件中
#删除如下语句
export PATH=username/anaconda3/bin:$PATH
#最后更新你的配置文件
source ~/.bashrc 或者 source /etc/profile

3.最后关闭终端然后重启即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容