Apache looks for Python 2.6 instead of 2.7 - python

My OS already has Python 2.6.6 and I've installed Python 2.7.3 as an alternative. (Python's working fine). I've installed mod_python also, but when I try to execute a Python file on an Apache server, it shows me a list of errors where I can see it seeks to Python 2.6.6 library. But I need to work with python 2.7.3. Can anyone help me to get rid of it?
Actually I don't know if Apache is configured well or not!
I'm on CentOS 6.2.

Have a look at this. However, note this part:
If you want to use a different version of major/minor version of Python than currently used, you must recompile mod_wsgi against the alternate version of Python.
I'm not quite sure that if you simply swap the WSGIPythonHome variable it will work. If you have installed mod_wsgi with yum, you will probably have a mod_wsgi for Python 2.6.x, which is distributed with CentOS 6.x. If you really want to use Python 2.7.x, you may have to build mod_wsgi from source (which is actually not that hard).

Related

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

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.
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.
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.
For RedHat based operating systems, use SCL versions of Python.
https://www.softwarecollections.org/en/
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:
https://pypi.python.org/pypi/mod_wsgi

Apache mod_wsgi 32-bit/64-bit Python compatibility

I use Zend Studio / Zend Server for developing my PHP-based web sites, but now I'm taking a course in Python, and I want to learn Django.
I have a Windows 7 AMD-64 machine, and am using 64-bit Python 2.6 (version 2.6 is required by the course), and that part works fine.
My problem is trying to add mod_wsgi to my Zend Server's 32-bit Apache installation. I've downloaded several versions of mod_wsgi 32-bit Windows binaries for Python 2.6, and copied them to C:Program Files (x86)\Zend\Apache2\modules directory, edited httpd.conf and added:
LoadModule wsgi_module modules/mod_wsgi.so
restarted Apached2.2-Zend, and then tested if mod_wsgi was loaded at the command prompt with:
httpd -t -M
However, mod_wsgi does not show up on the list of loaded modules.
I finally figured this might not be working because I cannot mix-and-match 64-bit Python 2.6 with 32-bit ZendServer Apache2.2.
So here's the meat of my question:
Can I install a 64-bit version of Apache 2.2 and run that at the same time as ZendServer Apache2.2 (but configure the 64-bit version so it doesn't listen on the same ports as my ZendSever Apache2.2) so all my local PHP virtual hosts still work? Maybe I would have better luck getting mod_wsgi to load with this Apache?
Or, would it be better to install a 32-bit version of Python (probably a higher version like Python 2.8, since I only need Python 2.6 for my coursework, and I am trying to get Django working just for my own web site development)? Would that allow my ZendServer Apache2.2 to load mod_wsgi? Also, how does Apache figure out which installation of Python it should be using if I have both on my Windows 7 machine?
Can I install a 64-bit version of Apache 2.2 and run that at the same time as ZendServer Apache2.2 (but configure the 64-bit version so it doesn't listen on the same ports as my ZendSever Apache2.2)
Yes, you can.
You've already thought about the hardest problem: that it can't listen on the same ports.
A related problem is that some people's networks don't allow them to make outgoing connections to, say, port 8080; if you want to deal with that, you'll need to set up your ZendServer to act as a forward proxy for the other server. But that's really about it.
The only other problem is that you need to make sure your two copies of Apache don't try to share the same config files, etc. (and you may not want both of them on your PATH, either).
Or, would it be better to install a 32-bit version of Python (probably a higher version like Python 2.8
There is no 2.8, and never will be. The last 2.x version is 2.7 (although it continues to get bug fixes, and is up to 2.7.5). If you want something higher, you have to go to 3.x. If everything you need runs on 3.3 (and Django 1.5+ does), and you're willing to learn the small changes, you should consider this. But if you want to stick with what you already know, get 2.7.5.
Would that allow my ZendServer Apache2.2 to load mod_wsgi?
Well, not if you're using a mod_wsgi for Python 2.6 and install a Python 2.7 or 3.3… or using a mod_wsgi for native Python and install a Cygwin Python… etc. But I suspect you already know that (given "I've downloaded several versions of mod_wsgi 32-bit Windows binaries for Python 2.6").
Other than that, yes. As long as everything is built and configured right, it will work. (I have no idea what particular packages you downloaded and installed, so I can't promise whether they will work, of course.)
Also, how does Apache figure out which installation of Python it should be using if I have both on my Windows 7 machine?
This is configurable. I believe the default is to use either whatever it finds first on your PATH, or whatever shows up as the "default python 2.x" in your registry settings, as used by the Python command-line launcher described in PEP 397. (And of course if that Python is not the one it was built against, it will fail to start up.)

Need MAMP to use (an older version of) Python

One of my sites requires python and cherrypy. Locally, I need to get all of this running with MAMP. I have the site running in MAMP with the exception of features reliant on Python. I need to run python 2.5. My OS version is 2.7.
How do I set this up? I seem to have 2.5 installed in addition to 2.7 and 2.6
which python
/usr/bin/python
which python2.5
/usr/bin/python2.5
but the usr/bin/python2.5 is an alias to: System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
How do I make python2.5 available to MAMP without screwing up the vers OSX needs?
It's a drupal site, MAMP is handling everything php related, and perhaps I wrongfully assumed it needed to have anything to do with the python scripts of the site. As I read more about cherrypy, it seems cherrypy serves the python scripts, and I do have cherrypy running (localhost:8080 test works anyway), so perhaps all I need to do is make sure python2.5 is being used instead of the default? (2.7)
You've got the right idea. You definitely want to leave the OS python version alone. Or you could be breaking multiple dependencies. We launch our cherrypy instances in our rc.local script at boot. This is where you specify which version of python to use when executing your cherrypy app.
Our rc.local script looks like this:
/opt/Python-3.2/python /var/www/html/appname/webapp.py > stdout.log &

python 2.6 vs 2.7, for pylons/pyramid projects

What problems can I have if I will use python 2.7 instead python 2.6 for my pylons/pyramid projects? Before I use python 2.6 on my ubuntu 10.04 but now I have ubuntu 11.04 on my laptop with python 2.7.
If you're using Ubuntu the package manager will fix most of the minor issues such as finding the packages you used to have in 2.6.
But there are some Packages that isn't compliant with Python2.7.
Mainly Python2.7 is a backwards compatible version from 3.X, or at least Python 2.7 was an upgrade from 2.6 towards the 3.X syntax and all it's new functions while the translation to 3.X was made.
Here's some info:
http://docs.python.org/dev/whatsnew/2.7.html
http://www.python.org/getit/releases/2.7/
Mainly Python2.7 should just give you more functions but can cause unexpected problems,
Go ahead and upgrade it on a seperate machine, run your code, if it works, upgrade your real machine to Python2.7.
The problems that might occur are minor, you should be able to fix them within 1h.
According to this post, Pyramid 1.2 (as is 1.1) is fully supported on Python 2.5.x, 2.6.x, and 2.7.x so you should be all set. From my own personal experience,I haven't run into any issues with Pyramid/Python2.7.
These days my Pyramid stack consists of:
python 2.7
khufu
sqlalchemy 0.7.x
and it works quite well.
Take a look at http://docs.python.org/dev/whatsnew/2.7.html
You'll find what all you'll ever need to know.

python 2.6.4 doesn't support mod_python?

am looking for a way to run django by just using my xampp, and i bumped into this tutorial online
http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html
according to the author, mod_python 3.3.1 is not supported by python 2.6, but the blog post was created more then a year ago i think. is this thing still true until now? or its ok if I will use 2.6 and combine it with mod python 3.3.1 ?
mod_python must be compiled against the specific version of Python that the handler will be run in. At the time there was probably no Windows installer for mod_python built against 2.6.4, hence the hysteria.
In all fairness, you should probably be using mod_wsgi to run Django apps instead.

Categories

Resources