全文包括:
- 显示目前使用的源channel
- 增加channel
- 删除channel
- 其他命令
1 显示channel:
首先,conda config --show
能够显示出所有conda的config信息。
C:\Users\mcj>conda config --show add_anaconda_token: True add_pip_as_python_dependency: True aggressive_update_packages: - ca-certificates - certifi - openssl allow_non_channel_urls: False allow_softlinks: False always_copy: False always_softlink: False always_yes: None anaconda_upload: None auto_update_conda: True changeps1: True channel_alias: https://conda.anaconda.org channel_priority: True channels: - defaults client_ssl_cert: None client_ssl_cert_key: None clobber: False create_default_packages: [] custom_channels: pkgs/main: https://repo.anaconda.com pkgs/free: https://repo.anaconda.com pkgs/r: https://repo.anaconda.com pkgs/pro: https://repo.anaconda.com pkgs/msys2: https://repo.anaconda.com custom_multichannels: defaults: ["https://repo.anaconda.com/pkgs/main", "https://repo.anaconda.com/pkgs/free", "https://repo.anaconda.com/pkgs/r", "https://repo.anaconda.com/pkgs/pro", "https://repo.anaconda.com/pkgs/msys2"] local: [] default_channels: - https://repo.anaconda.com/pkgs/main - https://repo.anaconda.com/pkgs/free - https://repo.anaconda.com/pkgs/r - https://repo.anaconda.com/pkgs/pro - https://repo.anaconda.com/pkgs/msys2 disallowed_packages: [] download_only: False envs_dirs: - E:\ProgramData\Anaconda3\envs - C:\Users\mcj\AppData\Local\conda\conda\envs - C:\Users\mcj\.conda\envs force: False json: False local_repodata_ttl: 1 max_shlvl: 2 migrated_channel_aliases: [] no_dependencies: False non_admin_enabled: True notify_outdated_conda: True offline: False override_channels_enabled: True path_conflict: clobber pinned_packages: [] pkgs_dirs: - E:\ProgramData\Anaconda3\pkgs - C:\Users\mcj\AppData\Local\conda\conda\pkgs proxy_servers: {} quiet: False remote_connect_timeout_secs: 9.15 remote_max_retries: 3 remote_read_timeout_secs: 60.0 report_errors: None rollback_enabled: True safety_checks: warn shortcuts: True show_channel_urls: True ssl_verify: True track_features: [] use_index_cache: False use_pip: True verbosity: 0 whitelist_channels: []
如果只是想看channel的信息,直接在后面机上channel即可conda config –show channels:
C:\Users\mcj>conda config --show channels channels: - defaults
一个默认源。
2 增加channel
根据官网提示,添加以下两个源(新增一个pytorch源):
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 --set show_channel_urls yes
conda config –set show_channel_urls yes的意思是从channel中安装包时显示channel的url,这样就可以知道包的安装来源了。
3 删除channel
上面三个源中,conda-forge不可用,因此,我们需要删除这个channel,输入:
conda config --remove channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
这时,这个源就被删除了。
C:\Users\mcj>conda config --show channels channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - defaults
或者是打开channels
存储文件,直接删除里面的channels
,文件位置:~/.condarc
最后一步:
4 其他常用conda命令
新建环境:conda create -n 环境名 python=3.6
激活环境:conda activate 环境名
退出环境:conda deactivate
删除环境:conda remove -n 包名 –all
查看所有环境:conda env list
复制环境:conda create –name 新环境名 –clone 旧环境名
查看已安装包:conda list
更新某个包:conda update 包名
卸载某个包:conda uninstall 包名
查看包所有版本:conda search 包名
安装指定版本包:conda install 包名=版本号
分享或迁移环境:http://www.machunjie.com/python/103.html
设置Windows下Jupyter Notebook默认工作目录:http://www.machunjie.com/python/102.html
5 参考链接
[1] Annaconda 增加删除镜像 channel, 以及其他python包安装解决办法 https://blog.csdn.net/mtj66/article/details/57074986
最开始是看到这里的评论,发现清华的源用不了。