Ubuntu虚拟机中Anaconda无法更新问题求助
问题描述
- 系统环境:Windows 10 上的 VirtualBox 虚拟机,Ubuntu 20.04.4 系统
- 安装软件:Anaconda 4.7.12(对应 Python 2.7.16)
- 操作过程:
最初尝试用anaconda update anaconda命令更新,之后执行conda update conda,得到输出:bioinfo@bioinfo:~$ conda update conda Collecting package metadata (current_repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.7.12 latest version: 4.13.0 Please update conda by running $ conda update -n base -c defaults conda # All requested packages already installed. - 执行
conda info返回信息:bioinfo@bioinfo:~$ conda info active environment : None shell level : 0 user config file : /home/bioinfo/.condarc populated config files : conda version : 4.7.12 conda-build version : 3.18.9 python version : 2.7.16.final.0 virtual packages : base environment : /home/bioinfo/anaconda2 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /home/bioinfo/anaconda2/pkgs /home/bioinfo/.conda/pkgs envs directories : /home/bioinfo/anaconda2/envs /home/bioinfo/.conda/envs platform : linux-64 user-agent : conda/4.7.12 requests/2.22.0 CPython/2.7.16 Linux/5.13.0-52-generic ubuntu/20.04.4 glibc/2.31 UID:GID : 1000:1000 netrc file : None offline mode : False - 疑问:为何 conda 无法完成更新?
解决方法
核心原因是你安装的是基于 Python 2.7 的 Anaconda2,而 conda 4.13.0 及更高版本已停止对 Python 2.7 的支持。Python 2 早在 2020 年就终止维护,Anaconda 官方也停止了对 Anaconda2 的更新服务,所以常规更新命令无法生效。
你有两种可行方案:
升级到基于 Python 3 的 Anaconda3
- 先备份当前 Anaconda2 环境中的重要包和项目文件
- 下载最新版 Anaconda3 安装包,优先选择全新安装(避免版本冲突)
- 重新配置你的开发环境和依赖包
若必须保留 Python 2.7 环境
- 只能维持当前的 conda 4.7.12 版本,这是支持 Python 2.7 的最后几个 conda 版本之一
- 后续无法获得 conda 的功能更新和安全补丁,建议尽早迁移到 Python 3
另外注意:anaconda update anaconda 是旧版 Anaconda Navigator 的命令,当前更新 conda 的标准命令是 conda update -n base conda,但受限于版本兼容性,这个命令在你的环境中无法完成升级。
内容的提问来源于stack exchange,提问作者Giamma Fer
相关产品推荐
相关产品推荐

