2014-09-03 171 views
3

我试图在Python 2.7.8上安装CentOS 6.5上安装的matplotlib-1.4.0。我试过用pip和源码安装。我最初收到一条错误消息,指出我需要更新版本的Freetype2,然后我将它安装到(版本2.5.3)/ usr/local/bin,/ usr/local/include和/ usr/local/lib。旧版本的Freetype2(2.3.11)位于/ usr/bin,/ usr/include/freetype2/freetype和/ usr/lib中。在CentOS 6.5上安装Matplotlib

现在,当我尝试安装matplotlib(python setup.py build)时,它看起来像包含路径都指向Freetype2的错误(旧)版本,我无法弄清楚如何将适当的路径更改为指向更新版本的Freetype2。实际的错误信息在下方,而且非常混乱。我无法在网上找到有关他的错误的更多信息,但是我可以看到错误的Freetype2路径,所以我猜这就是导致问题的原因。有小费吗?

发现有关将/ usr/include/freetype符号链接添加到/ usr/local/include/freetype2的其他线程的提示,但这并没有帮助。

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 
+0

我会删除该FreeType的符号链接,因为它可能会破坏你的系统上的其他东西。否则,你的错误似乎与蟒蛇2.7安装。你能对抗2.6吗? – daryl 2014-09-05 15:07:03

+0

我想我可能已经在这里找到了一个可能的解决方案:https://groups.google.com/forum/#!topic/modwsgi/Ev4iULHB3ms看起来像在构建Python时可以在配置脚本中包含--enable-shared选项解决这个问题。对于我来说,从头开始重新构建Python会很困难,因为它位于多个用户可能在任何给定时间使用的集群上......如果我能够尝试重新安装,我将进行更新。 – commanderdata 2014-09-17 23:19:54

回答

1

我终于有时间回到这个了,它与Freetype无关。这个问题是在编译期间拾取了libpython2.7的错误版本。特别是在这一行:

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 

第一-L目录是/ usr/local/lib目录含有不同版本的Python库(libpython2.7.a)比我应该已经编制反对。我暂时移动了这个文件,然后构建成功了(它在/usr/local/python2/2.7.8/x86_64/gcc46/nonet/lib中找到了正确的版本)。

我不是很确定/ usr/local/lib中的python lib源自哪里。如果是系统版本,那么这可能被认为是matplotlib构建脚本中的一个错误。

+0

我也遇到这个问题。有没有办法在Matplotlib中设置前缀/ python版本? – hlin117 2016-04-02 23:29:15

+0

不是我所知道的。 – commanderdata 2016-04-06 18:36:22

1

虽然我使用python-2.6我只是bodged一种方法,通过完全相同的FreeType的错误:基本上,你可以简单地下载matplotlib蟒蛇存档和编辑要求的FreeType-2.4的FreeType-2.3。这一切都是在虚拟环境中自然完成的。

  1. 得到当前最新的matplotlib

    的副本PIP安装 - 表格下载。 matplotlib == 1.4.0

  2. 解压结果 焦油-xzvf matplotlib-1.4.0.tar.gz

  3. 编辑的FreeType的明确要求从2.4到2.3(线945)

    VI matplotlib-1.4.0/setupext.py

    MIN_VERSION = '2.4',版本=版本)

  4. 重建归档

    焦油-czvf matplotlib-1.4.0.tar.gz

  5. 安装要求

    PIP安装numpy的

    PIP安装GeoJSON的== 1.0.6

  6. 安装修改后的地方归档和查看

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

+0

我应该补充说这个[1]是假设Freetype 2.3应该没问题的理由:1. https://github.com/mdboom/matplotlib/commit/96a3ea27cb0525704eacbe1b483a2479cdad19dc – 2014-09-15 02:58:24

+0

我从来没有想过要尝试这样做。它是否通过了所有(或大部分)测试?看起来好奇的是,如果不需要的话,开发者会执行2.4。感谢您花时间在此,我会在接下来的几天尝试一下,并让您知道它是如何发生的。 – commanderdata 2014-09-15 14:53:46

+0

我只跑了这些,并且有一组13次失败。不太清楚它们是什么: (matplotlibcopy)$ python ./tests.py -sv --processes = 5 --process-timeout = 300 Ran 4663 tests in 425.891s FAILED(KNOWNFAIL = 378,SKIP = 8 ,错误= 2,失败= 13) – 2014-09-15 21:53:15

0

从源代码编译matplotlib-1.4.3时,我也有这个问题。出现这个错误后,我只需export LDFLAGS="/home/ubuntu/softwares/python-2.7.11/lib",然后python setup.py install。错误消失了,我可以成功安装matplotlib。

0

如果你想在的CentOS 6(目前6.9当我写这篇)与的Python 2.6安装最新的matplotlib兼容版本,这里是我如何做。

登录为root,类型:

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