0

Could you please let me know the best way to upgrade python on linux? I need it because my redhat linux machine is offering 2.6.6 version as default. If I install python 2.7 then it breaks yum and mod_wsgi. Has anyone found out the best way to do it? I really need this for flask web development.

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).

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.

dganesh2002
  • 1,917
  • 1
  • 26
  • 29

3 Answers3

0

You can install multiple versions of python side-by-side. What makes one "default" is the python and python2 symlinks in /usr/bin.

However you should definitely not change the default python on Redhat for the reasons you list and more.

Instead, you will need to tell WSGI which python to use. This question covers that: Run mod_wsgi with virtualenv or Python with version different that system default

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.

Community
  • 1
  • 1
SpliFF
  • 38,186
  • 16
  • 91
  • 120
0

In addition to what SpliFF said, you can create a virtual environment and set which python version you would like to use by using the -p flag.

0

For RedHat based operating systems, use SCL versions of Python.

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. Details in:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134