English 中文(简体)
Trouble Upgrading Python / Django on CentOS
原标题:

As you can see by reading my other thread today here, I m having some troubles upgrading Python.

At the moment I have Python 2.4 with Django installed on a CentOS machine. However I ve recently deployed an application that requires 2.5 which has resulted in me installing that and getting into a whole load of mess. My original assumption was that I could direct Django to a different Python version, however as S.Lott informed me, I had it backwards... you attach Django to Python, not the other way round. Which means I currently have: Python 2.4 with Django and Python 2.5.

I ve tried a few things so far to no avail. The first idea being an easy_install which would put Django onto the Python 2.5 (So I d have 2 versions of python with seperate Djangos). Therefore I went into 2.5 s directory and did that, which then allowed me to find out that it had just reinstalls it on 2.4, not 2.5. Therefore first question is How do I direct easy_install to Python 2.5, not 2.4?

Is there no way to just hit upgrade and for a full update to occur? I know this may be asking for much, however it just seems like so much hassle and I m surprised I can t find anyone else complaining. Any help would be greatly appreciated.

最佳回答

I don t know anything about CentOS, but if you have multiple Python version installed and you wan t to install packages using easy_install, you just need to call it with the corresponding Python interpreter. This should install the packing into the site-package directory of Python 2.5:

# /path/to/python-2.5 easy_install Django
问题回答

assuming your python2.5 interpreter lives in /usr/bin/python2.5, you can install setuptools for python2.5 as such:

curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo /usr/bin/python2.5 ez_setup.py

Among other things, this installs an "easy_install-2.5" script in your $PATH (check the output of the above command).

Now you have two easy_install scripts: one for python 2.4 ("easy_install") and one for python 2.5 ("easy_install-2.5").

To install Django for your python2.5, use

sudo easy_install-2.5 django

That s it!

easy_install is a shell script the first line of which tells it where python is installed (I am on OSX so can t say exactly what your directories will be )

So you could copy easy_install and change the first line to point to 2.5. (or do as Heas suggests)

Althernatively when you installed python 2.5 there might be a file easy_install-2.5 with the correct python (again these were installed for me under OSX so might be a special version)

You don t need to install Django at all, it just needs to live on the Pythonpath somewhere. Assuming it s currently in the Python2.4 site-packages directory, you can just move it to the 2.5 one:

sudo mv /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django

or whatever the correct path is for CentOS.

However, as I noted on your other question, this won t necessarily help - S.Lott was unfortunately misleading in his answer. To serve Django via modpython or modwsgi with a new Python version, you ll need to recompile those extensions or download packages versions precompiled with Python 2.5.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签