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

常见问题

相关推荐
benjiangliu5 天前
恩培趣味计算机视觉-01-conda环境和Python库
开发语言·python·conda
weixin_461769409 天前
conda create 创建容器 Failed to resolve ‘repo.anaconda.com‘问题
开发语言·python·conda·repo·网络问题·无法创建
饭来_13 天前
Ubuntu 中出现 CondaToSNonInteractiveError 的解决方法
ubuntu·conda·debug
emo_2b15 天前
Pycharm配置conda解释器时遇到的问题及解决方法
linux·pycharm·conda
Είναι η κοπέλα17 天前
llama.cpp 与 GGUF 格式:本地大模型的“裸引擎“
开发语言·人工智能·pytorch·python·conda
Είναι η κοπέλα19 天前
显存计算与模型选择:你的显卡能跑多大的模型
人工智能·pytorch·python·开源·conda
天蓝蓝的本我19 天前
conda日常用到的命令积累1-登录linux,安装pycharm
linux·pycharm·conda
Είναι η κοπέλα21 天前
Python 虚拟环境:venv、conda 与 Python 版本选择全解
开发语言·python·conda
夏天拐跑了西瓜23 天前
一文入门LangChain:从框架认知到构建你的第一个AI Agent
python·langchain·conda·agent
weixin_4617694024 天前
机械臂SDK运行日志
conda·sdk