Thursday, November 18, 2021

[SOLVED] Installing matplotlib on RedHat ideally using yum

Issue

I can't seem to find documentation on this. Matplotlib says to run:

sudo yum install python-matplotlib

which installs all the dependancies and this version of matplotlib successfully:

python-matplotlib.x86_64 0:0.99.1.2-1.6.amzn1

However, I use python2.7, separately installed. The original (and still existing) python2.6 now imports matplotlib successfully. Is there a related matplotlib package on RedHat for python2.7? I don't know how to use this page on python-matplotlib packages.

Other info:

  • which python2.6 returns /usr/bin/python2.6
  • which python returns /usr/bin/python.
  • cat /proc/version returns
    Linux version 3.14.23-22.44.amzn1.x86_64 ... (Red Hat 4.8.2-16) (GCC) ...

Something else I tried:
I also tried to use pip2.7 instead, installed all the dependancies, and it broke on this issue concerning permissions. The solution is to reset the permissions of the problem file with:

chmod o+x /path/to/file

However, it's a temporary copied file. :( During the install of matplotlib it recopies this file over, so I can't set permissions on it. Here is the place it is broken:

g++ ... -lpython2.7 -o build/lib.linux-x86_64-2.7/matplotlib/backends/_backend_agg.so
running install_lib
copying pylab.py -> /usr/lib64/python2.7/site-packages
error: [Errno 13] Permission denied: '/usr/lib64/python2.7/site-packages/pylab.py'

This doesn't seem like the right way to do it, it's too cobbled together.

Question asked first at the Unix&Linux stackexchange.


Solution

I built from source. :( Surprisingly not that difficult, but ran into a lot of problems doing the interactive part (Redhat 4 is too old to have packages for most things that let you do interactive backends, I need a newer machine).

# get matplotlib
wget https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.4.3/matplotlib-1.4.3.tar.gz

#uncompress
tar xvzf matplotlib-1.4.3.tar.gz

# open build install
# read INSTALL file for more instructions
cd matplotlib-1.4.3
python setup.py build
# actually installing needed superuser privileges
sudo python setup.py install

Hope this saves time for anyone else with a similar setup.



Answered By - ehacinom