Conda常用的命令总结
- **1.Conda Management**
- **2. Manage the virtual enviroment**
- Show the info of help about *conda create*
- Create vitual enviroment
- Delete the vitual env
- Create the specific version of python of other pacakges
- Install pacakges for virtual env
- If you want to install specific pacakges when creating a new env , you can make it by modifying the file *.condarc*
- Clone a env
- Show all envs
- Create a same Conda env (not bying clone)
- Activate a new env
- View the pacakges list
- Use pip
- **3. Share ur env**
- **4. 通道管理**
- **5.卸载Anaconda**
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.最后关闭终端然后重启即可
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/