简体   繁体   English

如何在Linux(Redhat)上升级默认的python版本?

[英]How to upgrade default python version on linux (redhat)?

Could you please let me know the best way to upgrade python on linux? 您能告诉我在Linux上升级python的最佳方法吗? I need it because my redhat linux machine is offering 2.6.6 version as default. 我需要它,因为我的redhat linux机器默认提供2.6.6版本。 If I install python 2.7 then it breaks yum and mod_wsgi. 如果我安装python 2.7,则它将破坏yum和mod_wsgi。 Has anyone found out the best way to do it? 有没有人找到最好的方法呢? I really need this for flask web development. 我真的需要这个来进行Flask Web开发。

I had tried https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/ steps but it caused issues with mod_wsgi (which was on 2.6). 我已经尝试过https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/步骤,但它导致mod_wsgi(在2.6上)出现问题。

Just to add - I have read and tried almost everything related to this topic but couldn't succeed. 补充一下-我已经阅读并尝试了与该主题相关的几乎所有内容,但未能成功。 Hence I am asking this question if someone has already figured out a way for this. 因此,我在问这个问题,是否有人已经找到解决方法。

You can install multiple versions of python side-by-side. 您可以并排安装多个版本的python。 What makes one "default" is the python and python2 symlinks in /usr/bin . 使“默认”成为一个的是/usr/binpythonpython2符号链接。

However you should definitely not change the default python on Redhat for the reasons you list and more. 但是,出于列出原因及其他原因,您绝对不应更改Redhat上的默认python。

Instead, you will need to tell WSGI which python to use. 相反,您将需要告诉WSGI使用哪个python。 This question covers that: Run mod_wsgi with virtualenv or Python with version different that system default 这个问题涵盖了这一点: 使用virtualenv或版本与系统默认版本不同的Python运行mod_wsgi

Also, according to this answer ( Deploying Python Flask App on Apache with Python version installed in Virtual Environment Only ) you may need to compile a custom wsgi against the python version you want to use. 另外,根据此答案( 仅在Virtual Environment中安装了Python版本的情况下,在Apache上部署Python Flask App ),您可能需要针对要使用的python版本编译自定义wsgi。

除了SpliFF所说的之外,您还可以通过-p标志创建一个虚拟环境并设置要使用的python版本。

For RedHat based operating systems, use SCL versions of Python. 对于基于RedHat的操作系统,请使用Python的SCL版本。

They are installed in separate area so they do not conflict. 它们安装在单独的区域中,因此不会发生冲突。

There is no mod_wsgi in SCL, so use pip method to install it and then link Apache to it. SCL中没有mod_wsgi,因此请使用pip方法安装它,然后将Apache链接到它。 Details in: 详细信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM