mac跟新python

下载新python

python数据官网下载(这里以python3.9.0a5为例)https://www.python.org/ftp/python/3.9.0/Python-3.9.0a5.tgz

安装新python

  1. 解压缩python文件:tar -zxvf Python-3.9.0a5.tar
  2. 进入python编译文件夹:cd ./Python-3.9.0a5
  3. 配置、安装:./configure(报错configure: error: no acceptable C compiler found in $PATH参见结尾报错排除)
  4. 编译:make
  5. make安装make install
  6. 验证:python3 -V

跟改python指向

执行:

cd ~
vim .bash_profile

执行结果:在这里插入图片描述
输入:

# python
alias python=python3

完成后:
在这里插入图片描述

检查

执行:python -V
结果:在这里插入图片描述

报错排除

在第二部分第3步,执行./configure是如有报错:
执行:
yum install make gcc gcc-c++排错(这个故障我这里没有,参考知乎文献(地址在参考文献中)

参考文献

知乎:Linux 升级 Python 至 3.x@爬向墙头[转载一去丶二三里]

最简单的办法:anaconda

运行

conda update python

就完事了

扫描二维码关注公众号,回复: 12183530 查看本文章

版权声明

版权归本文参考文献作者以及本人所有,转载请声明出处(懒得写就当没看见,不追究,自己知道就行)

作者

hit-road

拜拜,下课!

猜你喜欢

转载自blog.csdn.net/weixin_42954615/article/details/105206453