Python学习之前期准备

Python学习之前期准备


前言

计划开始学习python后,参考了多个网站的教学资源,各类教学视频目不暇接;内心还是想从一些基础学起,一点一点打好基础。这一篇记录我在linux上安装Python的一些操作,遇到的问题及解决方案。


一、安装linux操作系统并配置yum源

操作系统是很久之前就安装好的centos8.3
1.查看当前系统
[root@localhost ~]# cat /proc/version
Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020
2.配置yum源
我在配置yum源是出现了报错,附配置yum报错的原因及解决方法。
参考阿里云官网指导:https://help.aliyun.com/document_detail/405635.html?spm=5176.12818093.help.dexternal.5adc16d05uG3c2

操作完上述之后仍然报如下错误:
Errors during downloading metadata for repository ‘epel-archive’:

  • Curl error (6): Couldn’t resolve host name for http://mirrors.cloud.aliyuncs .com/epel-archive/8/Everything/x86_64/repodata/repomd.xml [Could not resolve hos t: mirrors.cloud.aliyuncs.com]
    Error: Failed to download metadata for repo ‘epel-archive’: Cannot download repo md.xml: Cannot download repodata/repomd.xml: All mirrors were tried

操作
经过检查发现是epel-archive这部分配置中的http://mirrors.cloud.aliyuncs.com/epel-archive/8/Everything/x86_64/repodata/repomd.xml 这个地址不可达,
排查:
[root@localhost yum.repos.d]# cat epel-archive-8.repo //查看这个文件 发现镜像中的地址已经失效,原因是centos8停止维护,阿里云的源镜像库做了对应的调整。
[epel-archive]
name=Extra Packages for Enterprise Linux 8 - b a s e a r c h b a s e u r l = h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / e p e l − a r c h i v e / 8 / E v e r y t h i n g / basearch baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/8/Everything/ basearchbaseurl=http://mirrors.cloud.aliyuncs.com/epelarchive/8/Everything/basearch
enabled=1
gpgcheck=0

[epel-archive-debuginfo]
name=Extra Packages for Enterprise Linux 8 - b a s e a r c h − D e b u g b a s e u r l = h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / e p e l − a r c h i v e / 8 / E v e r y t h i n g / basearch - Debug baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/8/Everything/ basearchDebugbaseurl=http://mirrors.cloud.aliyuncs.com/epelarchive/8/Everything/basearch/debug
enabled=0
gpgcheck=0

[epel-archive-source]
name=Extra Packages for Enterprise Linux 8 - $basearch - Source
baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/8/Everything/SRPMS
enabled=0
gpgcheck=0
[root@localhost yum.repos.d]# vim epel-archive-8.repo
//将这个文件中的http://mirrors.cloud.aliyuncs.com 全部替换成http://mirrors.aliyun.com
[root@localhost yum.repos.d]# vim epel-archive-8.repo
[epel-archive]
name=Extra Packages for Enterprise Linux 8 - b a s e a r c h b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / e p e l − a r c h i v e / 8 / E v e r y t h i n g / basearch baseurl=http://mirrors.aliyun.com/epel-archive/8/Everything/ basearchbaseurl=http://mirrors.aliyun.com/epelarchive/8/Everything/basearch
enabled=1
gpgcheck=0

[epel-archive-debuginfo]
name=Extra Packages for Enterprise Linux 8 - b a s e a r c h − D e b u g b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / e p e l − a r c h i v e / 8 / E v e r y t h i n g / basearch - Debug baseurl=http://mirrors.aliyun.com/epel-archive/8/Everything/ basearchDebugbaseurl=http://mirrors.aliyun.com/epelarchive/8/Everything/basearch/debug
enabled=0
gpgcheck=0

[epel-archive-source]
name=Extra Packages for Enterprise Linux 8 - $basearch - Source
baseurl=http://mirrors.aliyun.com/epel-archive/8/Everything/SRPMS
enabled=0
gpgcheck=0
~
~
运行一下命令重新创建缓存,这次成功了。yum源配置完成,以上所有的基础是操作系统能够访问外网
yum clean all && yum makecache
在这里插入图片描述

二、升级centos8至centos stream

CentOS 8迁移至Stream版本的方式如下:

[root@centos ~]# dnf swap centos-linux-repos centos-stream-repos
[root@centos ~]# dnf distro-sync

参考了这位大神的文章:FAQ - CentOS Project shifts focus to CentOS Stream
————————————————
版权声明:本文为CSDN博主「dotnba」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ldy/article/details/121454918
在这里插入图片描述

三、安装python39

命令很简单,输入 yum install python39 之后 会下载一些包,并做对应的检查和处理
在这里插入图片描述
安装成功,测试一下

[root@localhost yum.repos.d]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

KeyboardInterrupt
>>>
[2]+  Stopped                 python3
[root@localhost yum.repos.d]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>
>>>


总结

以上就是这次基础环境搭建的方法。记录了踩的坑;
算是解决了几个问题
配置yum、升级centos版本、安装python

实际使用还在后面,继续学习。 还不太清楚是否正确,今天就先写到这里,该回家给老婆孩子做饭了,遇到了一个问题,知道的大神可以帮忙解答下。
我满以为安装成功, 但是安装的python39,查版本确实 Python 3.6.8 不知道是为什么? 还是说系统本身就自带了Python,我装的并没有成功? ,今天先不研究了,回家再看。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值