具体操作如下:
step1:首先在菜单中,以管理员的身份启动 Anaconda Prompt,如图1所示;
step2:升级conda(升级Anaconda前需要先升级conda)命令为:
conda update conda
step3:升级anconda命令为:
conda update anaconda
step4:升级python命令为:
conda update python
step5:升级spyder命令为:
conda update spyder
- 安装/更新单个库:以安装 更新 scipy 为例
pip install scipy
pip install scipy --upgrade
# 或者
conda install scipy
conda update scipy
step6:
conda update --all
ps:
使用conda安装软件,总是出现无法安装的提示:
Collecting package metadata: failed
UnavailableInvalidChannel: The channel is not accessible or is invalid.
channel name: anaconda/cloud/bioconda
channel url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
error code: 404
You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.
原来清华大学停止了镜像服务:
关于停止Anaconda镜像服务的通知
https://mirror.tuna.tsinghua.edu.cn/news/close-anaconda-service/
解决方法:
使用
conda config --remove-key channels
将提示的镜像源全部删除即可。
增加r、conda-forge、bioconda的channels:
conda config --add channels r # R软件包
conda config --add channels conda-forge # Conda社区维护的不在默认通道中的软件
conda config --add channels bioconda # 生物信息学类工具
在执行 conda config 命令的时候
会在当前用户目录下创建 .condarc 文件,可以查看更换源前后该文件内容的变化。
查看配置文件
conda config --show
添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
显示安装的频道
conda config --set show_channel_urls yes
查看已经添加的channels
conda config --get channels
已添加的channel在哪里查看
vim ~/.condarc
此时,目录 C:\Users<你的用户名> 下就会生成配置文件.condarc,内容如下:
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
各系统都可以通过修改用户目录下的 .condarc
文件:
清华大学开源软件镜像站 https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
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
上海交通大学开源镜像站
channels:
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
中国科学技术大学 USTC Mirror
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
————————————————
2、修改配置文件
删除上述配置文件 .condarc 中的第三行,然后保存,最终版本文件如下:
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
3、查看是否生效
通过命令
conda info
查看当前配置信息
当然, 也可以用这个命令进行搜索
conda search spyder
安装完成后,可以用“which 软件名”来查看该软件安装的位置:
which gatk
如需要安装特定的版本:
conda install 软件名=版本号
conda install spyder=3.7
这时conda会先卸载已安装版本,然后重新安装指定版本。
查看已安装软件:
conda list
更新指定软件:
conda update spyder
卸载指定软件:
conda remove spyder
==========================慎用===========================
异常终极解决方式:
File "E:\software\Anaconda3\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "E:\software\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "E:\software\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 362873 column 16 (char 10796875)
## 删除索引缓存、锁定文件、未使用过的包和tar包。
conda clean --all
==================================
conda环境使用基本命令
conda update -n base conda #update最新版本的conda
conda create -n xxxx python=3.5 #创建python3.5的xxxx虚拟环境
conda activate xxxx #开启xxxx环境
conda deactivate #关闭环境
conda env list #显示所有的虚拟环境
conda info --envs #显示所有的虚拟环境
查看指定包可安装版本信息命令
参考:https://blog.csdn.net/qq_35203425/article/details/79965389
查看tensorflow各个版本:(查看会发现有一大堆TensorFlow源,但是不能随便选,选择可以用查找命令定位)
anaconda search -t conda tensorflow
查看指定包可安装版本信息命令
anaconda show <USER/PACKAGE>
查看指定anaconda/tensorflow版本信息
anaconda show tensorflow
输出结果会提供一个下载地址,使用下面命令就可指定安装1.8.0版本tensorflow
conda install --channel https://conda.anaconda.org/anaconda tensorflow=1.8.0
更新,卸载安装包:
conda list #查看已经安装的文件包
conda list -n xxx #指定查看xxx虚拟环境下安装的package
conda update xxx #更新xxx文件包
conda uninstall xxx #卸载xxx文件包
删除虚拟环境
conda remove -n xxxx --all //创建xxxx虚拟环境
清理(conda瘦身)
conda clean就可以轻松搞定!第一步:通过conda clean -p来删除一些没用的包,这个命令会检查哪些包没有在包缓存中被硬依赖到其他地方,并删除它们。第二步:通过conda clean -t可以将删除conda保存下来的tar包。
conda clean -p //删除没有用的包
conda clean -t //删除tar包
conda clean -y -all //删除所有的安装包及cache
参考:https://blog.csdn.net/menc15/article/details/71477949
重命名env
Conda是没有重命名环境的功能的, 要实现这个基本需求, 只能通过愚蠢的克隆-删除的过程。
切记不要直接mv移动环境的文件夹来重命名, 会导致一系列无法想象的错误的发生!
conda create --name newname --clone oldname //克隆环境
conda remove --name oldname --all //彻底删除旧环境
conda自动开启/关闭激活
参考:https://www.cnblogs.com/clemente/p/11231539.html
conda activate #默认激活base环境
conda activate xxx #激活xxx环境
conda deactivate #关闭当前环境
conda config --set auto_activate_base false #关闭自动激活状态
conda config --set auto_activate_base true #关闭自动激活状态
Conda 安装本地包
有时conda或pip源下载速度太慢,install a过程中会中断连接导致压缩包下载不全,
此时,我们可以用浏览器等工具先下载指定包再用conda或pip进行本地安装
#pip 安装本地包
pip install ~/Downloads/a.whl
#conda 安装本地包
conda install --use-local ~/Downloads/a.tar.bz2
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/14008.html