Yelneerg
Yelneerg

Reputation: 171

Installing a python module when more than one version of python is installed on the system

So here's the situation. We have a server running Scientific Linux 5.5 and the newest version of python in the base repos is 2.4. I really need a newer version and I discovered that python 2.6 could be installed via yum as python26 from the EPEL repos.

I also need the python libraries numpy and matplotlib to be available to the python26 install. Python26-numpy is available in the EPEL repo but there isn't a python26 version of matplotlib available.

To summarize:
python 2.4 installed with numpy and matplotlib form base repos (but I need newer versions)
python 2.6 installed with numpy as python26 from EPEL repos, BUT matplotlib unavailable.

I assume there must be a way to manual install matplotlib such that it can be accessed by the python26 install, but I'm not sure what the proper/best way to go about doing it is and I don't want to skrew anything up on this server since my whole group uses it.

Upvotes: 1

Views: 119

Answers (1)

khampson
khampson

Reputation: 15326

My suggestion would be to install virtualenv (http://docs.python-guide.org/en/latest/dev/virtualenvs/) and then install all the packages you need (including numpy and matplotlib) inside of that virtualenv. Then, you would run your code inside that virtualenv, and it would not affect anyone else nor the base Python install.

(The only thing you would need to install in the base Python installer would be pip and virtualenv if they are not already present).

Others in your group could then also create their own virtualenv's for their needs, containing various other packages, and not overlap with each other.

The environment can also be stored in a requirements file via the output from pip freeze and checked into source control, and then used to re-create the same virtualenv elsewhere (useful for situations such as use with Jenkins, test environments, etc.).

Upvotes: 2

Related Questions