Installing Matplotlib on CentOS 6.5

I am trying to get matplotlib-1.4.0 installed on CentOS 6.5 with Python 2.7.8. I tried to install with pip and from source. I first got an error that I needed a newer version of Freetype2, which I then installed (version 2.5.3) in / usr / local / bin, / usr / local / include and / usr / local / lib. An older version of Freetype2 (2.3.11) is located in / usr / bin, / usr / include / freetype2 / freetype and / usr / lib.

Now when I try to install matplotlib (python setup.py build) it looks like the include paths are pointing to the wrong (old) version of Freetype2 and I can't figure out how to change the corresponding dot paths to the newer version of Freetype2. The actual error message is below and it's pretty messy. I couldn't find much about his error on the internet, but I can see that the Freetype2 path is wrong, so I guess this is causing the problem. Any advice?

Found tips on other topics about adding / usr / include / freetype symlink to point to / usr / local / include / freetype 2, but that didn't help.

building 'matplotlib.ft2font' extension
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c src/ft2font.cpp -o build/temp.linux-x86_64-2.7/src/ft2font.o
In file included from /usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
                 from /usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from src/file_compat.h:7,
                 from src/ft2font.cpp:7:
/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
In file included from src/ft2font.cpp:7:0:
src/file_compat.h:31:0: warning: "npy_fseek" redefined [enabled by default]
/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include/numpy/npy_common.h:86:0: note: this is the location of the previous definition
src/file_compat.h:32:0: warning: "npy_ftell" redefined [enabled by default]
/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include/numpy/npy_common.h:91:0: note: this is the location of the previous definition
src/ft2font.cpp: In member function ‘Py::Object FT2Image::py_write_bitmap(const Py::Tuple&)’:
src/ft2font.cpp:184:15: warning: unused variable ‘offset’ [-Wunused-variable]
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c src/mplutils.cpp -o build/temp.linux-x86_64-2.7/src/mplutils.o
In file included from /usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7/Python.h:8:0,
                 from src/mplutils.h:18,
                 from src/mplutils.cpp:6:
/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
/usr/include/features.h:162:0: note: this is the location of the previous definition
/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7/pyconfig.h:1204:0: warning: "_XOPEN_SOURCE" redefined [enabled by default]
/usr/include/features.h:164:0: note: this is the location of the previous definition
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c extern/CXX/cxxsupport.cxx -o build/temp.linux-x86_64-2.7/extern/CXX/cxxsupport.o
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c extern/CXX/cxx_extensions.cxx -o build/temp.linux-x86_64-2.7/extern/CXX/cxx_extensions.o
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c extern/CXX/IndirectPythonInterface.cxx -o build/temp.linux-x86_64-2.7/extern/CXX/IndirectPythonInterface.o
gcc -pthread -fno-strict-aliasing -O3 -m64 -mfpmath=sse -msse2 -mtune=generic -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib/python2.7/site-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -Iextern -I/usr/local/python2/2.7.8/x86_64/gcc46/nonet/include/python2.7 -c extern/CXX/cxxextensions.c -o build/temp.linux-x86_64-2.7/extern/CXX/cxxextensions.o
g++ -pthread -shared build/temp.linux-x86_64-2.7/src/ft2font.o build/temp.linux-x86_64-2.7/src/mplutils.o build/temp.linux-x86_64-2.7/extern/CXX/cxxsupport.o build/temp.linux-x86_64-2.7/extern/CXX/cxx_extensions.o build/temp.linux-x86_64-2.7/extern/CXX/IndirectPythonInterface.o build/temp.linux-x86_64-2.7/extern/CXX/cxxextensions.o -L/usr/local/lib -L/usr/local/lib64 -L/usr/lib -L/usr/lib64 -L/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib -lfreetype -lstdc++ -lm -lpython2.7 -o build/lib.linux-x86_64-2.7/matplotlib/ft2font.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1  

      

+3


source to share


4 answers


Finally I got back to it, and it had nothing to do with Freetype. The problem was the wrong version of libpython2.7 that was built at build time. Specifically on this line:

g++ -pthread -shared build/temp.linux-x86_64-2.7/src/ft2font.o build/temp.linux-x86_64-2.7/src/mplutils.o build/temp.linux-x86_64-2.7/extern/CXX/cxxsupport.o build/temp.linux-x86_64-2.7/extern/CXX/cxx_extensions.o build/temp.linux-x86_64-2.7/extern/CXX/IndirectPythonInterface.o build/temp.linux-x86_64-2.7/extern/CXX/cxxextensions.o -L/usr/local/lib -L/usr/local/lib64 -L/usr/lib -L/usr/lib64 -L/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib -lfreetype -lstdc++ -lm -lpython2.7 -o build/lib.linux-x86_64-2.7/matplotlib/ft2font.so

      



The first -L directory is / usr / local / lib, which contains a different version of the python library (libpython2.7.a) than the one I should have compiled. I moved this file temporarily and the build was successful (it found the correct version in / usr / local / python 2 / 2.7.8 / x86_64 / gcc46 / nonet / lib).

I'm not really sure where the python lib came from in / usr / local / lib. If this is a system version, then this can be considered a bug in the matplotlib build script.

+1


source


Although I am using python-2.6, I was just looking for the same freetype error: essentially, you can just download the matplotlib python archive and edit the requirement for freetype-2.4 for freetype-2.3. All this was done in virtual mode, of course.



  • get a copy of the current latest matplotlib

    pip install --download. Matplotlib == 1.4.0

  • parse the output tar -xzvf matplotlib-1.4.0.tar.gz

  • edit explicit requirement for freetype 2.4 to 2.3 (line 945)

    vi matplotlib-1.4.0 / setupext.py

    min_version = '2.4', version = version)

  • create archive

    tar -czvf matplotlib-1.4.0.tar.gz

  • set requirements

    pip install numpy

    pip install geojson == 1.0.6

  • Install the modified local archive and see how it compiles

    pip install --verbose matplotlib-1.4.0.tar.gz

+1


source


I also have this problem when compiling matplotlib-1.4.3 from source. After this error I just export LDFLAGS="/home/ubuntu/softwares/python-2.7.11/lib"

, then python setup.py install

. The error is gone and I can install matplotlib successfully.

0


source


If you want to install the most recent Python 2.6matplotlib

compatible version on CentOS 6 (currently 6.9 when I wrote this), here's how I did it.

Recorded root

, enter:

sudo yum install -y epel-release
sudo yum install -y python-pip
sudo yum install -y gcc gcc-c++ python-argparse python-devel freetype-devel libpng-devel
pip install --upgrade pip
pip install numpy==1.11.3  # latest version working with Python 2.6
pip install --upgrade distribute  # required by matplotlib 1.4
pip install -I setuptools  # "distribute" installation will remove setuptools, so we need to reinstall it
pip install matplotlib==1.4.3  # latest version working with Python 2.6

      

0


source







All Articles