4

I have Python2.6.5 and Python2.4.4 on my linux machine.

At the moment, all the modules I have (wx, ply, pyserial, twisted, to name a few) are installed for the 2.6 version of python. If I try to import wx on Python2.4, I get the expected no module error.

The problem here, is that I have a lot of devices (Let's say over a thousand) all running 2.4.4, which will soon need to be supported by this machine (For builds of code, releases etc). Until now, I've been using an EeePC (Same device as the ones I'm supporting) to do builds and releases, which has worked well. (I develop on the 2.6 machine, and build on the EeePC).

How would I go about getting these modules to work for Python2.4? I've tried reinstalling (With 2.4 as my primary), but that just caused errors. The blogs/answers I've found say to use easy_install, but that doesn't support the packages I need (Or at least, it just died when I tried).

In short: I'm currently using python 2,6, but I'd like it to change to 2.4 for all the modules as that's what I'm going to be using.

3
  • "I've tried reinstalling (With 2.4 as my primary), but that just caused errors. " - How about telling us what the errors were? Commented Feb 14, 2011 at 11:10
  • E: /var/cache/apt/archives/python-wxgtk2.8_2.8.11.0-0_i386.deb: subprocess new pre-removal script returned error exit status 1 As far as I can tell, it's due to setting python2.4 as my primary python install. I'm not really sure though Commented Feb 14, 2011 at 11:22
  • apt-get can only be used to install packages for the pythons you install with apt. I doubt it's related (unless you have installed Python2.4 in such a way that /usr/bin/python2.6 now is Python2.4 which I doubt. It's probably not a good idea to let /usr/bin/python be 2.4 either, but /usr/local/bin/python should be fine). Commented Feb 14, 2011 at 12:03

2 Answers 2

5

You can't share modules between different versions of Python. If you want to use wxPython from Python 2.4, you need to install it for Python 2.4.

You said you tried to install it with Python 2.4 as your "primary". I'm not sure what that means. You would install wxPython for Python 2.4 by running the installer with Python 2.4, like so:

$sudo /usr/bin/python2.4 setup.py install

Or similar.

You can use easy_install as well, but then you need to install Distribute for Python 2.4 first. Did you do that?

I recently wrote a full explanation on my blog about this: http://regebro.wordpress.com/2011/02/02/newbie-hint-on-installing-python-and-its-modules-and-packages/

Sign up to request clarification or add additional context in comments.

6 Comments

By primary, I meant the main installation of python (Python2.4 used make install, whilst 2.6 used make altinstall). I was hoping there'd be a way to share the modules, but looks like I'll need to install them all seperately. Ah well. I've tried easy_install, with Distribute - it works for python2.4, but fails on getting the versions of modules I need to use. (Due to the 1k+ devices out on-the-field which can't update, I'm stuck on older module versions. Annoying, yes, but sadly nothing I can do for it). I'll mark yours as the accepted answer as it gives a very good explanation. Thanks!
@TyrantWave: Thanks! Post questions on the actual errors you get too, easy_install shouldn't have any problems in getting specific versions.
@Lennart Regebro: I'd like to, but that's the odd part: It just doesn't do anything when it comes to ply or py_serial. I'm not sure why, but it left me quite confused. No error, nothing returned.
@TyrantWave: easy_install prints out a lot of things when you run it, so I seriously doubt it doesn't say anything.
@Lennart Regebro: Usually yes. For some odd reason, ply and pyserial it says Reading . It works fine for everything else (Even wxPython, which can't be easy_installed). Beats me, but I've got the sources and installed those. Only thing left is installing wxPython on an older version, which eludes me - compiling wx from source is a nightmare I'd rather not do...
|
3

Don't attempt to share them; this has some chance of success with pure Python modules, but C modules will fail to work. Instead, install them using the appropriate interpreter executable, e.g. python2.4 setup.py install.

1 Comment

Thanks IVA (your name too long to type ) . your answer helped me to switch from python 3 to python 2 and vice-versa .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.