Python 官方文档:入门教程 => 点击学习
目录 一、更新原因 二、步骤 2.1、添加conda下载镜像 2.2、conda更新python 2.3、更新conda版本 三、验证 四、离线安装 一、更新原因
目录
原因是本来使用的是具有python3.6.3版本的conda环境,但是因为python内存堆栈溢出的bug问题。现在需要将Python的版本更新到3.8.8或3.9.2及以上。在更新的过程还是有几个细节需要注意下,这边做个记录。
方法有两种,一种是conda install命令更新,另一种是直接下载sh更新。前者比较繁琐且容易出错。第二种相对简单很多。
第二种方式简单,这边简单讲一下。下载sh后直接拷贝到对应linux目录后安装,具体可参考这篇文章:linux安装anaconda3环境-CSDN博客 。sh下载地址是:Index of / ,其中部分的anaconda对应的python列表如下(都是一个一个安装后 python -V 试出来的):
Anaconda3-2020.07-Linux-x86_64.sh | python3.8.3 |
Anaconda3-2020.11-Linux-x86_64.sh | python3.8.5 |
Anaconda3-2021.04-Linux-x86_64.sh | python3.8.8 |
Anaconda3-2021.11-Linux-x86_64.sh | python3.9.7 |
这个是为了让你在下载的时候使用国内镜像源地址下载,有效提高下载速度。
# 将下面内容添加到 ~/.condarcchannels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - Https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - defaultsshow_channel_urls: truedefault_channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/rcustom_channels: conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud PyTorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudssl_verify: false
如果conda的版本跟python的版本不兼容了。具体体现于下面的报错:
[root@finance205 home]# conda -VTraceback (most recent call last): File "/root/anaconda3/bin/conda", line 7, in from conda.cli import mainModuleNotFoundError: No module named 'conda'
我们只需升级下conda版本即可,升级命令如下:
conda update conda
conda install python=3.8.8
如果升级的python版本跨度太大,则要注意一些语法或函数参数在搞版本里是否有弃用更改等情况。如果在conda install python 不指定python=多少版本,那么会默认给你安装最新的。
上面操作完成后,可以验证下我们的conda及python安装情况:
# 查看conda版本conda -V# 查看python版本python -V
如果是离线的话,使用第二种方式方便一些。得注意需要同步离线安装bzip2包。
来源地址:https://blog.csdn.net/zkkkkkkkkkkkkk/article/details/129835799
--结束END--
本文标题: 使用conda更新python版本
本文链接: https://www.lsjlt.com/news/401016.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0