Anaconda常用命令
tips:
- 命令不好用时,可在前面 加 conda(如:activate testpy不好用,就换成conda activate testpy)
1.创建/删除环境
#用conda创建一个名为testpy的python 3.7虚拟环境
conda create -n testpy python=3.7
#查看conda虚拟环境
conda env list
#进入conda虚拟环境
activate Qt5env
#退出conda虚拟环境
deactivate
#删除环境testpy
conda remove -n testpy --all
2.替换下载源
#查看当前下载源
conda config --show-sources
#添加源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
#从channel中安装包时显示channel的url,这样就可以知道包的安装来源
conda config --set show_channel_urls yes
#还原默认源
conda config --remove-key channels
3.查看下载了哪些包
#pip能用,conda也有这功能
pip list
conda list
# 查看当前环境下numpy库的版本
pip show numpy
4.安装/卸载包
#安装包
pip install numpy
conda install numpy
# 安装 NumPy 库,并指定版本 1.12.5
pip install numpy==1.21.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 Pandas 库,并指定版本 1.2.4
pip install Pandas==1.2.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 Matplotlib 库,并指定版本 3.5.1
pip install Matplotlib==3.5.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
#卸载包
pip uninstall numpy
conda uninstall numpy