Jorey Bump
list at joreybump.com
Tue Apr 8 16:39:59 EDT 2008
Joseph Bernhardt wrote, at 04/08/2008 04:14 PM: > When starting a new python process via > Popen, it is not only using an older version of python installed on > the server, but is also using the module paths associated with that > version! I realize that this is no longer a mod_python problem, but > I have been unable to post to the python-list or python-help forums > through python.org (don't know why, but it keeps being returned as > though my address has been blocked), so I was hoping you could tell > me how to change the default python version on RHEL 2.6.9? I have > been searching all over and can't find how it is to be done! On most systems, python is just a symlink to another binary: $ which python /usr/bin/python $ ls -l /usr/bin/python lrwxrwxrwx 1 root root 9 2007-07-23 17:10 /usr/bin/python -> python2.5 For my example, I might do this (as root): rm /usr/bin/python ln -s /usr/local/bin/python3.0 /usr/bin/python However, you probably shouldn't do this. Many distributions (and I think especially RHEL) provide system utilities written in python, and they target the version provided with the distribution. You could easily break your system or other applications that depend on python. A better alternative would be to specify the full path to the desired version of python in your popen statement: subprocess.Popen(['/usr/local/bin/python3.0 myapp.py', shell=True) This is not very portable, but that's what you get when you install multiple versions of python. Remember to change your code when you migrate it (or develop on a system where you can leave the defaults alone). Of course, it's pretty strange to popen a python app in mod_python. Does it need to be a subprocess, as opposed to simply importing it and exposing a public API? The latter approach would be more beneficial in the long run.
|