文章目录
查看conda版本
conda --version
安装包
conda install xxx //安装xxx包
卸载包
conda uninstall xxx //卸载xxx包
更新包
conda update xxxx
xxxx除了是报名外,还可以是anaconda, spyder等。
conda update --all
#更新所有包
搜索安装包
anaconda search -t conda XXX //搜索安装包
查看已安装的包
conda list
更换清华下载源
查看conda的下载源
conda config --show-sources
利用命令行更换conda源更换为清华
只需输入如下两行命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
更新更全的清华源
在windows系统自己用户的目录下面新建一txt文件,更名为.condarc,写入以下信息
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
如果需要换回conda的默认源。命令如下:
conda config --remove-key channels
利用conda创建新的python环境
anaconda可以虚拟创建多个互相独立的python环境
这里我们创建并激活一个名为“py36_tensoflow”的python环境
打开Anaconda Prompt,键入如下命令:
conda create --name <env_name:环境名称> <package_names:环境中需要包含的包名>
conda create --name py36_tensorflow python=3.6
activate py36_tensorflow
退出刚刚创建的python环境
deactivate
之后可以执行`conda info --envs`命令,验证刚刚所创建的环境是否成功
环境处理的其他代码
切换环境:
source activate <env_name>
退出环境:
source deactivate
显示已创建的环境:
conda info --envs
复制环境:
conda create --name <new_env_name> --clone <copied_env_name>
删除环境:
conda remove --name <env_name> --all
查找包: * 精确查找
conda search --full-name <package_full_name>
模糊查找
conda search <text>
查看当前环境中已安装的包:
conda list
在指定环境中安装包:
conda install --name <env_name> <package_name>
conda install --name <env_name> -c conda-forge <package_name>
conda install --name <env_name> -c anaconda <package_name>
在使用conda无法安装时,可以在某个环境下使用pip安装:
pip install <package_name>
卸载包:
conda remove --name <env_name> <package_name>
使用 requirements.txt 安装:
conda install --yes --file requirements.txt --name <env_name>
requirements.txt文件格式如下:
tensorflow==1.10.0
markupsafe
itsdangerous
wtforms==2.2.1
gevent==1.1.1
python-engineio==2.1.0
python-socketio==1.9.0
Flask==1.0.2
flask-wtf==0.14.2
flask-socketio==3.0.0
pandas==0.23.4
six
jpype1==0.6.3
gensim==3.4.0
jieba
scikit-learn
conda 添加镜像源:
conda config --add channels anaconda
conda config --add channels conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
参考
https://blog.csdn.net/weixin_35656285/article/details/112138760