2014-09-03 137 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