导航:首页 > 编程语言 > redhat升级python

redhat升级python

发布时间:2023-04-27 08:15:48

A. python版本升级后之前安装的库要重新安装吗

1,windows,在控制面板中卸载原来亮没的安装程序,如果还有没删除的文件,如果需要保留下次安装可以覆盖,一般不影响第三方库的使用。
2,linux下,编译安装还是升级整个系统,比如centos,redhat等系统yum可能需要使用python2比较低的版本,所以不要删除原来的程序,将yum的python解析器指定为原来哪毕版本,新版本可以编译安装在其他目录,然后环境变量修改为新版本即可敬缓纳。

B. red hat怎么升级python

从今天开始学习Python!看了一下虚拟机RedHat中的python,发现还是原生的2.4.3,所以决兆庆吵定升级一下
[root@linuxidc ~]# python
Python 2.4.3 (#1, May 5 2011, 16:39:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>>
[root@linuxidc ~]#
1.下载z最新版本的python
[root@linuxidc ~]# wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz
2.解压及编译
[root@linuxidc ~]# tar xvf Python-2.7.2.tar.bz2
[root@linuxidc Python-2.7.6]# ./configure --prefix=/usr/local/python27
[root@linuxidc Python-2.7.6]# make
[root@linuxidc Python-2.7.6]# make install
[root@linuxidc Python-2.7.6]# ls /usr/local/python27/ -al
total 28
drwxr-xr-x 6 root root 4096 Mar 21 01:01 .
drwxr-xr-x 13 root root 4096 Mar 21 01:01 ..
drwxr-xr-x 2 root root 4096 Mar 21 01:01 bin
drwxr-xr-x 3 root root 4096 Mar 21 01:01 include
drwxr-xr-x 4 root root 4096 Mar 21 01:01 lib
drwxr-xr-x 3 root root 4096 Mar 21 01:01 share
3.覆差晌盖原有的python链接
[root@linuxidc Python-2.7.6]# mv /usr/bin/python /usr/bin/python_old
[root@linuxidc Python-2.7.6]# ln -s /usr/local/python27/bin/python /usr/bin/
[root@linuxidc Python-2.7.6]# python
Python 2.7.6 (default, Mar 21 2014, 01:00:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>>
此时已经可以正常使族侍用python2.7了,但是因为yum是使用的2.4的版本来用的,现在输入一下yum就会报错
[root@linuxidc Python-2.7.6]# yum
There was a problem importing one of the Python moles
required to run yum. The error leading to this problem was:
No mole named yum
Please install a package which provides this mole, or
verify that the mole is installed correctly.
It's possible that the above mole doesn't match the
current version of Python, which is:
2.7.6 (default, Mar 21 2014, 01:00:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://wiki.linux.ke.e/YumFaq
5.修改yum
[root@linuxidc Python-2.7.6]# vim /usr/bin/yum
#!/usr/bin/python #修改此处为2.4的位置
[root@linuxidc Python-2.7.6]# vim /usr/bin/yum
#!/usr/bin/python2.4
yum 可以使用了!
[root@linuxidc Python-2.7.6]# yum
Loaded plugins: rhnplugin, security
You need to give some command
usage: yum [options] COMMAND
List of Commands:
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
erase Remove a package or packages from your system
groupinfo Display details about a package group
groupinstall Install the packages in a group on your system
grouplist List available package groups
groupremove Remove the packages in a group from your system
help Display a helpful usage message
info Display details about a package or group of packages
info-security Returns security data for the packages listed, that affects your system
install Install a package or packages on your system
list List a package or groups of packages
list-security Returns security data for the packages listed, that affects your system
localinstall Install a local RPM
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repolist Display the configured software repositories
resolvedep Determine which package provides the given dependency
search Search package details for the given string
shell Run an interactive yum shell
update Update a package or packages on your system
update-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your system
upgrade Update packages taking obsoletes into account

options:
-h, --help show this help message and exit
-t, --tolerant be tolerant of errors
-C run entirely from cache, don't update cache
-c [config file] config file location
-R [minutes] maximum command wait time
-d [debug level] debugging output level
--showplicates show plicates, in repos, in list/search commands
-e [error level] error output level
-q, --quiet quiet operation
-v, --verbose verbose operation
-y answer yes for all questions
--version show Yum version and exit
--installroot=[path] set install root
--enablerepo=[repo] enable one or more repositories (wildcards allowed)
--disablerepo=[repo] disable one or more repositories (wildcards allowed)
-x [package], --exclude=[package]
exclude package(s) by name or glob
--disableexcludes=[repo]
disable exclude from main, for a repo or for
everything
--obsoletes enable obsoletes processing ring updates
--noplugins disable Yum plugins
--nogpgcheck disable gpg signature checking
--disableplugin=[plugin]
disable plugins by name
--enableplugin=[plugin]
enable plugins by name
--skip-broken skip packages with depsolving problems
--security Include security relevant packages
--cve=CVE Include packages needed to fix the given CVE
--bz=BZ Include packages needed to fix the given BZ
--advisory=ADVISORY Include packages needed to fix the given advisory
[root@linuxidc Python-2.7.6]#

C. linux怎么升级python版本

如果是redhat/centos, 使用sudo yum -y update即可. 如果源里的新版本不能达到你的要求, 你可以去python.org下载最新版并手动编译, 如果python.org里的最新版仍不能达到你的要求, 你可以对源码进行修改编译并测试.

D. 在centos 7上安装并配置python 3.6环境,怎样使用3.6.1 版本

在CentOS 7上安装并配置Python 3.6环境
在纯净的 CentOS 系统上安装 Python 环境主要有两种办法。 一种是通过源码编译安装,另外一种就是安装已经打好的 RPM 包。依照个人习惯,我们先来看一下如何通过源码编译的方式安装 Python 3.6 并且配置虚拟环境。
作者:TaoBeier来源:segmentfault|2017-06-26 18:30
移动端
收藏
分享

拖了很久没有更新,抱歉啦~ 今天受邀写篇如何在 CentOS 7 上配置 Python 3 环境的文章。往常我都选择直接把我早年写的一篇文章源码编译MongoDB丢过去,让他们看其中的源码编译 Python 那一节,不过那节写的其实不太详细,而且最近被很多人催,所以还是单独写一篇好了。
当前最新的 CentOS 7.3 默认安装的是 Python 2 ,并且默认的官方 yum 源中不提供 Python 3 的安装包。有些用户想要升级使用 Python 3 但实际可能有各种各样的问题,导致出错,反观一下激进的 Fedora 社区,在23的时候,就将默认的版本修改成了 Python3 (如果我没记错的话)。
先说下我所使用的系统环境, 一个新创建的 Docker 容器。 使用 cat /etc/redhat-release 可以看到运行的是 CentOS 7.3 版本。

在纯净的 CentOS 系统上安装 Python 环境主要有两种办法。 一种是通过源码编译安装,另外一种就是安装已经打好的 RPM 包。依照个人习惯,我们先来看一下如何通过源码编译的方式安装 Python 3.6 并且配置虚拟环境。
使用源码进行编译安装
基础环境
先安装安装几个必须的包,以方便后续的操作
➜ yum install wget gcc make ➜ # wget 用于下载源码包 ➜ # gcc 和 make 用于编译

上 Python的官网 下载源码包
➜ wget

解包,解压缩
➜ xz -d Python-3.6.1.tar.xz ➜ tar -xvf Python-3.6.1.tar

编译
➜ cd Python-3.6.1 ➜ ./configure --prefix=/usr/local/python3.6 --enable-optimizations ➜

先解释下上面的参数,--prefix 是预期安装目录,--enable-optimizations 是优化选项(LTO,PGO 等)加上这个 flag 编译后,性能有 10% 左右的优化(如果没记错的话),但是这会明显的增加编译时间。不过关于 LTO 和 PGO 其实不在今天文章的讨论范围内,建议感兴趣的可以看看 GCC 中 LTO 的具体实现。我应该不太可能去写相关的文章 哈哈哈 毕竟写起来就会停不下来。
接下来
➜ make ➜ make install

如图,会看到出错了,提示 zlib not available 所以,我们需要装一下依赖
➜ yum install zlib-devel

那为什么需要这个依赖包呢, 其实是因为 Python 有个很重要的内建模块 zipimport 用于从 Zip 压缩包中导入模块。 而如果没有 zlib 的包,那么就无法进行解压缩了,也自然该模块就不能使用了。
当我们的依赖安装好之后,重新执行上面的编译安装的步骤,发现执行成功。
➜ /usr/local/python3.6/bin/python3 --version Python 3.6.1

此刻,我们的 Python 3 也就安装成功了。
检查
编译安装完还远远不够,我们来做些检查。
当我们运行 Python 终端,输入 import bz2 的时候,会发现没有这个模块。如果你对这个模块不熟悉,那也没关系。我们输入 import sqlite3熟悉 Python 的同学应该对 sqlite3 不会太陌生,但如果你还是不熟悉的话,那你按方向键试试看。有没有发现,输出变成了^[[D^[[A 类似这样的内容?

熟悉 Python 源码的同学,肯定知道我要说什么了。但是假如你不熟悉,没关系,我来告诉你。正常来讲,在终端下我们预期当输入上方向键,会显示上一条命令,输入左方向键,可以将光标移动到左侧。但现实和我们的预期不同,什么原因?
这里涉及到了一点点关于输入设备的历史原因,简单来说就是需要有个模块来对用户的输入进行转义。回到本文的重点,就是我们编译安装的时候缺少了 readline 这个模块。既然已经发现了问题,那解决的办法其实很简单
➜ yum install readline-devel

安装完成后,重复上面的步骤,编译&&安装即可。
再检查
前面只是解决了方向键输入的问题,但是我提到的那两个模块还是 import 不进来,那我们仔细的看看我们的编译过程的输出。其中有这样的一段(依据系统环境的不同,输出可能也是不一致的)
Python build finished successfully! The necessary bits to build these optional moles were not found: _curses bz2 _dbm _gdbm _lzma _sqlite3 _tkinter readline To find the necessary bits, look in setup.py in detect_moles() for the mole's name.

按照上面的提示,很明显,我们缺少了一些(可选的)模块,这些模块假如你觉得自己不会用到,那也可以不理会它。这些模块,我用到的会多一些,甚至是那个一般人都不会碰的 TK 模块 哈哈哈。解决方式就只是装一下对应的模块即可。
➜ # 解决 import bz2 报错 ➜ yum install bzip2-devel ➜ # 解决 import curses 报错 ➜ yum install ncurses-devel ➜ # 解决 import sqlite3 报错 ➜ yum install sqlite-devel ➜ # 解决 _dbm _gdbm 缺失提醒 ➜ yum install gdbm-devel ➜ # 解决 _lzma 缺失提醒 ➜ yum install xz-devel ➜ # 解决 _tkinter 缺失提醒 ➜ yum install tk-devel ➜ # 解决 readline 缺失提醒及方向键行为非预期的问题 ➜ yum install readline-devel

当这些模块都装完,重新编译会发现提醒已经消失,安装即可。

使用 rpm 包进行安装
先来介绍一下 IUS 这个社区,名字的全写是【Inline with Upstream Stable】取首字母,它主要是一个提供新版本RPM包的社区。具体使用可以查看官方文档 简单说来就只要按下面的命令操作即可。
➜ yum -y install

添加 IUS 之后,先创建缓存元数据,再进行安装即可
➜ yum makecache ➜ yum install python36u ➜ yum -y install python36u-pip ➜ yum -y install python36u-devel

完成后直接终端输入 python3 即可。
环境配置
上面只是写了 Python 的安装,如果是使用 RPM 的方式安装的话,那直接是可用的。但如果是源码编译的,总不至于每次都输入一大串路径吧。所以解决方法很简单,加个链接即可。
➜ ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3

另外,当系统中存在多个 Python 版本的时候,尽量去避免环境污染。我个人比较推荐使用 virtualenv 创建独立的虚拟环境,我日常中也是这样用的。不过,当我们安装完 Python 3.6 后,可以直接执行下面的命令进行虚拟环境的创建。
➜ python3 -m venv py3 ➜ source py3/bin/activate (py3) ➜ python -V Python 3.6.1

总结
CentOS 7 上安装Python 3.6 主要有两种方式,源码编译和安装 RPM 包。
对于想快速使用源码配置环境但并不想关心具体原因的读者,可以直接使用我GitHub上提供的这个脚本进行安装
另外Python 3.6 可直接使用 python3 -m venv venv_name 创建虚拟环境。

E. 红帽八怎么安装chtony

红帽八怎么安装chtony按如下方法。
1、–首先更新RHEL上的软件包列表,并使用以下命令安装在RedHat上安装Python的前提条件。
2、更新软袭并枯件包后,可以蔽雀使用以下命令安装最新的Python3。
3、–安装Python之后,可以通过检查已安装的Python版拍洞本来对其进行验证。
4、如果屏幕还显示上述输出,则表示Python3.8已成功安装在RedHat系统上。

F. 如何在linux系统中安装python

Linux系统默认是安装有python,可以先在终端输入: python 然后看看是否有回显,如果有就不需要安装了。如果没有,可以按照下面得方法安装:
打开终端,输入:wget
下载完毕后 输入解压命令:tar –zxvf Python-3.5.0b4.tgz
切换到解压的目录:cd Python*
接下来就是安装:
./configure
make
make install
然后查看一下就知道了:
输入python如果出现下面的提示:
Python 3.5.0 (#1, Aug 06 2015, 14:04:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type “help”, “right”, “credits” or “license” for more information.
就说明成功了,因为linux系统可能不一样,第二行有可能不同哈。

G. python安装之后运行显示modify setup

现进入CMD,然后输入DOS命令进入setup.py文件所在目录,然后输入pythonsetup.pyinstall就搞定了。

如果你使用的操作系统是Windows:当前最稳定的斗则Windows版本下载是"Python3.8.3forWindows"。

如果你使用的是Mac,MacOS10.2(Jaguar),10.3(Panther)and10.4(Tiger)已经集成安装了Python,物庆但是你大概需要安装最近通用的构架罩销握(build)。

对于RedHat,安装python2和python2-devel包。

对于Debian,安装python2.5和python2.5-dev包。

H. redhat yum安装报错python(abi) = 2.4 is needed by...

试一下安装RPM Forge epel release 6。

I. 如何在已经存在python2的linux环境上安装python3

如何在已经存在python2的linux环境上安装python3

有的人态宽盯在安装的时候可能会先将python2解除安装掉,这个地方严重强调一下,不要去解除安装系统中已经存在的python2,否则会造成系统中好多其他需要python执行的程式异常
系统环境
[root@localhost install]# pwd
/data/install
[root@localhost install]# cat /etc/redhat-release
CentOS release 6.3 (Final)
[root@localhost install]# uname -a
Linux localhost 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
python3.4的安装方法
[root@localhost install]# wget :python./ftp/python/3.4.4/Python-3.4.4.tgz
[root@localhost install]# tar -zxf Python-3.4.4.tgz
[root@localhost install]# cd Python-3.4.4
# 在安装包中有一个README的档案帆和,里面有写如何安装
[root@localhost Python-3.4.4]# ls
aclocal.m4 config.sub configure.ac Grammar install-sh LICENSE Makefile.pre.in Moles Parser PCbuild Python setup.py
config.guess configure Doc Include Lib Mac Misc Objects PC pyconfig.h.in README Tools
[root@localhost Python-3.4.4]# ./configure
[root@localhost Python-3.4.4]# make
[root@localhost Python-3.4.4]# make install
测试
[root@localhost Python-3.4.4]# python3
Python 3.4.4 (default, Jun 27 2016, 07:47:54)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "right", "credits" or "license" for more information.
>>>
以后执行python程式就可以使用python3 程式名 去执行了

已经存在python2的linux环境上安装python3,有两种方法,第一种是替换python2,第二种是直接安装python3,而不替换python2,这样的话,在python3执行的时候,就要写成python3+启动等巧禅语句

J. AWS使用快照创建实例启动失败

 因业务需求,需要将A集群复制一份到B集群,当做预生产环运哗让境使用。但是在AWS使用快照的方式创建EC2实例的时候无法正常启动,通过获取AWS EC2截图能够看到已经到了登录界面。

 在发现问题后尝试使用 SSM 登录,但是却无法登录进系统内部。后再停止实例运行,然后在运行实例,依然无法启动。
为了排查是 VPC 的问题,还是实例镜像的问题。使用另外一台服务器的镜像启动,但是依然无效。最后在待实例进入 running 状态后,依次选择 Actions 、芦谈 Instance Settings 、 Get System Log 通过获取系统日志发现了一些问题。

在 /usr/bin/cloud-init 中修改 #!/usr/bin/python 为 #!/usr/bin/python2.7 然后手动创建快照。在用创建的快照从新启动一台新的实例来。

为了能够更好的解决这个问题。后来通过实际测试, centos7 系统中默认使用的 python 版本为 python2.7 ,我们通过使用 yum 安装,是不会覆盖掉系统的python版本。

所以建议,系统中同时存在两个 python 版本,您使用 yum 安装 python3 这样不会覆盖系统的 python 版本,在您不想使用系统 python2.7.x 而使用 python3 时,您直接在相应应用指明使用python的版本即可。
如果将 Centos7 中系统默认的 python 版本修改为 python3 时,这个可能会遇到各种各样的问题。
不过 python2.7 已经停止维护了,如果不想使用 python2.7 ,旁局目前可能只能通过升级系统的方式来解决这个问题, centos8 和 redhat8 系统默认使用的 python 版本都是 python3
文章原文
https://cnsre.cn/posts/210311132723

阅读全文

与redhat升级python相关的资料

热点内容
python高手之路pdf 浏览:82
iphone怎么像安卓一样返回 浏览:160
linuxtomcat端口占用怎么办 浏览:720
表演pdf 浏览:921
微信如何更换服务器 浏览:861
android使用html5 浏览:458
python可视化极坐标 浏览:384
程序员喜欢绿色 浏览:730
php编译的主流软件 浏览:364
操作系统服务器版本下载地址 浏览:245
手机管家加密图片打不开 浏览:839
基于单片机的智能散热器控制器的设计 浏览:471
pdfadobereaderxi 浏览:488
本田雅阁压缩机工作 浏览:680
河北编程排行榜 浏览:134
胸椎12轻度压缩性骨折 浏览:104
算法英文pdf 浏览:358
编译原理第3版清华课后答案第二章 浏览:165
长虹黑白单片机是什么电路 浏览:659
maven打war包命令 浏览:938