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升级。

常见问题

相关推荐
喜乐boy3 小时前
CV系列——Conda + PyTorch + CUDA + cuDNN + Python 环境无脑安装速查笔记[2025.12]
pytorch·python·conda·cuda·cv
祁思妙想4 小时前
【python】--- 创建Conda新环境/切换环境/安装
conda
Eric.Lee20217 小时前
ubuntu系统在bashrc文件中对conda进行启用设置
linux·运维·python·ubuntu·conda
啦啦右一1 天前
杂货铺 | 复现Github项目,用Conda解决旧版requirements.txt的TensorFlow冲突
github·conda·tensorflow
远瞻。2 天前
【环境配置】快速转移conda上的python环境
开发语言·python·conda
毅硕科技2 天前
毅硕HPC | 在HPC集群上优雅地使用Conda
conda·hpc·应用教程·高性能计算集群·专业服务
周杰伦_Jay2 天前
【Conda 完全指南】环境管理+包管理从入门到精通(含实操示例+表格对比)
开发语言·人工智能·微服务·架构·conda
runfarther4 天前
Windows下使用源码和Conda搭建GraphRAG指南
windows·conda·graphrag
进击切图仔5 天前
GraspNet 训练集下载、解释和整理
人工智能·pytorch·conda
wsj__WSJ5 天前
Python 项目管理工具 uv 详解
python·conda·virtualenv