Modules between multiple versions of Python Linux - python

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.

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/

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.

Related

Module Not Found Error with one version of of Python, but no the other

I am using a VS Code (Linux Mint) plug-in for Python that allows me to choose between different interpreters.
When I run my file with Python 3.8, I get an error saying that it can't find pandas I am trying to use, but when I switch the interpreter to Python 3.6 there is no issue finding pandas.
What's going on?
The module might not be updated for Python 3.8. Search up the module's name from GitHub or where it can be imported from to see what versions they support.
That module isn't installed for Python 3.8, simple as that. Different versions of Python have different libraries (listed under sys.path) on Debian-based distros.
Without knowing which module, it's hard to say much else, like whether it even supports 3.8, but to install it, you might be able to use apt or pip.

Python-2.7.2 on 6.2 PUIAS i386_64

I am not a regular Linux user so this might be completely trivial question. I am running 6.2 PUIAS version i386_64 on one of my GPU based "super" computers due to the unavailability of NVidia drivers for NetBSD. The installed version of Python is 2.6.6. I need 2.7.2 Python and newer version of scipy, numpy, matlibplot and friends. I have PUIAS and EPEL repositories enabled. However they do not have newer versions of Python. What is the "recommended" way to install newer version of Python without braking the system which depends on it. I am not interested in Python 3.2 due to the lack of libraries for scientific computing.
When the install-Python-from-source routine tells you to use make install, type make altinstall instead. This will leave the normal python executable untouched and instead create python2.7 for you to use. Install the other packages from source using this new executable. Don't forget to change the shebang line in your scripts accordingly.
I am going to answer my own question. For people who are using Python for scientific computing on RedHat clones (PUIAS for example) the easiest way to get all they need is to use rpm package manager and Enthought Python Distribution (EPD for short). EPD installs everything in a sandbox so system tools which are based on an obsolete version of Python are not massed up. However, paths have to be adjusted for system or even easier on the user base so that the using shell invokes non-system tools. One should never compile Python from source unless you are interesting in Python itself or in porting it to your favorite operating system rather than in your own research!

Getting shogun ML library to work with python

I was trying to install shogun on Windows:
http://www.shogun-toolbox.org/doc/installation.html
but evidently it requires python 2.5 to work. I tried with python 3 and it didn't work. But then python 2.5 no longer exists.
Does anybody know how to get it working with python without using python 2.5?
You won't get very far trying with Python 3 (which is not fully compatible with Python 2.x).
Furthermore, the installation instructions say:
"SHOGUN requires the standard linux
utils like bash, grep, test, sed, cut,
ldd, uname gcc g++ cat python"
sounds like you are out of luck on windows, unless you resort to Cygwin.
There are currently two Python languages out there
the original one, which is still being updated (currently at 2.7.2)
the overhauled Python 3, which is breaking compatibility (currently at 3.1.4)
Many libraries have not switched to Python 3 yet, and might not for some time, so you're better off getting 2.6 or 2.7.
For Windows or Mac, I can recommend the Enthought distribution (free for academic use), which contains loads of goodies, including scipy, which you'll very probably need -- and installs hassle-free!

Running both python 2.6 and 3.1 on the same machine

I'm currently toying with python at home and I'm planning to switch to python 3.1. The fact is that I have some scripts that use python 2.6 and I can't convert them since they use some modules that aren't available for python 3.1 atm. So I'm considering installing python 3.1 along with my python 2.6. I only found people on the internet that achieve that by compiling python from the source and use make altinstall instead of the classic make install. Anyway, I think compiling from the source is a bit complicated. I thought running two different versions of a program is easy on Linux (I run fedora 11 for the record). Any hint?
Thanks for reading.
On my Linux system (Ubuntu Jaunty), I have Python 2.5, 2.6 and 3.0 installed, just by installing the binary (deb) packages 'python2.5', 'python2.6' and 'python3.0' using apt-get. Perhaps Fedora packages them and names them as RPMs in a similar way.
I can run the one I need from the command line just by typing e.g. python2.6. So I can also specify the one I want at the top of my script by putting e.g.:
#!/usr/bin/python2.6
Download the python version you want to have as an alternative, untar it, and when you configure it, use --prefix=/my/alt/dir
Cheers
Nik
You're not supposed to need to run them together.
2.6 already has all of the 3.0 features. You can enable those features with from __future__ import statements.
It's much simpler run 2.6 (with some from __future__ import) until everything you need is in 3.x, then switch.
Why do you need to use make install at all? After having done make to compile python 3.x, just move the python folder somewhere, and create a symlink to the python executable in your ~/bin directory. Add that directory to your path if it isn't already, and you'll have a working python development version ready to be used. As long as the symlink itself is not named python (I've named mine py), you'll never experience any clashes.
An added benefit is that if you want to change to a new release of python 3.x, for example if you're following the beta releases, you simply download, compile and replace the folder with the new one.
It's slightly messy, but the messiness is confined to one directory, and I find it much more convenient than thinking about altinstalls and the like.

Upgrade python in linux

I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it?
The safest way to upgrading Python is to install it to a different location (away from the default system path).
To do this, download the source of python and do a
./configure --prefix=/opt
(Assuming you want to install it to /opt which is where most install non system dependant stuff to)
The reason why I say this is because some other system libraries may depend on the current version of python.
Another reason is that as you are doing your own custom development, it is much better to have control over what version of the libraries (or interpreters) you are using rather than have a operating system patch break something that was working before. A controlled upgrade is better than having the application break on you all of a sudden.
The UUID module exists as a separate package for Python 2.3 and up:
http://pypi.python.org/pypi/uuid/1.30
So you can either install that in your Python2.4, or install Python2.6. If your distro doesn't have it, then Python is quite simple to compile from source. Look through the requirements to make sure all the libraries you need/want are installed before compiling Python. That's it.
The best solution will be installing python2.6 in the choosen directory - It will you give you access to many great features and better memory handling (infamous python=2.4 memory leak problem).
I have got several pythons installed onto my two computers, I found that the best solution for are two directories:
$HOME/usr-32
$HOME/usr-64
respectively to using operating system (I share $HOME between 32 and 64 bit versions of Linux).
In each I have one directory for every application/program, for example:
ls ~/usr-64/python-2.6.2/
bin include lib share
It leads completetely to avoiding conflicts between version and gives great portability (you can use usb pendrives etc).
Python 2.6.2 in previously example has been installed with option:
./configure --prefix=$HOME/usr-64/python-2.6.2

Categories

Resources