conda疑难杂症

annaconda、miniconda和conda的关系

conda官网 https://docs.conda.io/projects/conda/en/latest/

下载安装Anaconda: https://www.anaconda.com/products/distribution#Downloads

下载安装Miniconda:https://docs.conda.io/en/latest/miniconda.html

安装

安装是需要使用官网下载的文件执行安装的。参考安装步骤链接

windows下好像需要手动添加环境变量,linux下如果找不到conda也需要添加环境变量

常用命令

  1. 查看帮助 conda env --help
  2. 列出所有的虚拟环境conda env list
  3. 创建 虚拟环境 同时安装 需要的包conda create --name envname python=x.x
  4. 创建一个和原python环境一样的虚拟环境 conda create --name dst_name --clone src_name
  5. 删除某个虚拟环境conda remove --name [虚拟环境名] --all
    激活某个环境
    conda activate [虚拟环境名]
    取消激活某个环境
    conda deactivate [虚拟环境名]

换源

下载速度过慢可以尝试更换源
清华源

bash 复制代码
vim ~/.condarc

清除原有内容,将下面内容复制进去。保存并退出。

bash 复制代码
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/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

最后,使用如下命令

bash 复制代码
 conda clean -i

如果出现了solving environment转圈然后失败,可能是因为你之前就已经通过命令行的方式换过源了,这将会导致换源后需要搜索的目标过大,从而导致解析失败。解决方法与上述一致,更新过后的源将会是非常干净的清华源。

当然,一直转圈的原因也有可能是conda版本过旧,可以使用如下方法更新conda

清理

bash 复制代码
conda clean -p      //删除没有用的包(推荐)
conda clean -t      //tar打包
conda clean -y -all //删除全部的安装包及cache
conda clean -a    //删除所有的缓存和无用包以及其他无用的东西

进入anaconda目录下du -sh *即可查看

pkgs中即为一些垃圾文件

升级

bash 复制代码
conda update -n base -c defaults conda

若失败,则尝试

bash 复制代码
conda update -n base -c defaults conda --repodata-fn=repodata.json

如果你已经发现更新了,但是没有到最新版本。继续重复以上操作提示所有工作已做完无需更新则。

可能的原因是最新版本对于base环境的python版本已经不支持了。

但是我没有测试过升级base环境中的python升级。

常见问题

相关推荐
弱冠少年3 天前
conda入门
conda
John Song3 天前
conda指定包安装的channel
conda
Gene_20223 天前
conda环境配置(一) —— 常用虚拟环境操作命令
conda
Calvex3 天前
PyCharm集成Conda环境
python·pycharm·conda
晓枫-迷麟3 天前
【使用conda】安装pytorch
人工智能·pytorch·conda
拾回程序猿的圈圈∞5 天前
PyCharm项目和文件运行时使用conda环境的教程
windows·pycharm·conda
weixin_478689766 天前
【conda配置深度学习环境】
人工智能·深度学习·conda
是Dream呀7 天前
IPython 使用技巧整理
conda·文心一言·ipython
love530love7 天前
【笔记】2025 年 Windows 系统下 abu 量化交易库部署与适配指南
大数据·运维·人工智能·windows·笔记·python·conda
CC_IsMe9 天前
Linux服务器 TensorFlow找不到GPU
linux·jupyter·ssh·conda·tensorflow