1

数日前、同じシステムにnumpyをインストールすることについて質問しました。ありがたいことに、私はそれを自分で解決することができましたが、残念ながら、matplotlibをインストールしようとして立ち往生しています。

まず、現在の配布バージョンを試しましたが、うまくいかなかったので、gitリポジトリをダウンロードして試してみようと思いました。私はこれまでに持っています:

  • make.osxPython3で動作するようにファイルを 変更しました。
    • import urllib->import urllib.request
    • urllib.urlretrieve()->urllib.request.urlretrieve()

その後も、freetype2ヘッダーが見つからないという問題がありました。私はグーグルで検索し、次の行を編集することでこれを解決できることを発見しましたsetupext.py

  • 'darwin' : [],->'darwin' : ['/usr/local'],

ただし、make.osxファイルを使用するとエラーメッセージが表示されます。ターミナルからファイルを呼び出す方法は次のとおりです。

  • sudo make -f make.osx PREFIX=/usr/local PYVERSION=3.2 fetch deps mpl_build mpl_install

matplotlibはまだPython3で公式にサポートされていないことに気づきましたが、少なくともどこかでコンパイル/インストールすることができたのではないかと思いました。

どんな助けでも大歓迎です、

アダム。

以下に表示されるエラーを含めました。

basedirlist is: ['/usr/local']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.2.x
                python: 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59)
                        [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
              platform: darwin

REQUIRED DEPENDENCIES
                 numpy: 1.6.2rc1
             freetype2: found, but unknown version (no pkg-config)

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
               Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: yes
                    Qt: no
                   Qt4: Qt: 4.7.4, PyQt4: 4.8.6
                PySide: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide
adding pytz

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: /bin/sh: gs: command not found
                 latex: no

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.macosx-10.6-intel-3.2/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.macosx-10.6-intel-3.2/matplotlib/mpl-data

running build_ext
building 'matplotlib.ft2font' extension
gcc-4.2 -DNDEBUG -g -O3 -arch i386 -arch x86_64 -I/usr/local/include -I/usr/local/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include -I/usr/local/include -I. -I/usr/local/include/freetype2 -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/freetype2 -I/usr/local/include/freetype2 -I./freetype2 -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c src/ft2font.cpp -o build/temp.macosx-10.6-intel-3.2/src/ft2font.o
In file included from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/bytearrayobject.h:9,
                 from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/Python.h:73,
                 from ./CXX/WrapPython.h:58,
                 from ./CXX/Extensions.hxx:37,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:45,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/char_traits.h:46,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/string:47,
                 from ./CXX/Python3/Exception.hxx:47,
                 from ./CXX/Python3/Objects.hxx:45,
                 from ./CXX/Python3/Extensions.hxx:52,
                 from ./CXX/Extensions.hxx:42,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h: In function ‘int std::__convert_from_v(int* const&, char*, int, const char*, ...)’:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h:77: error: ‘va_start’ was not declared in this scope
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h:85: error: ‘va_end’ was not declared in this scope
In file included from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/bytearrayobject.h:9,
                 from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/Python.h:73,
                 from ./CXX/WrapPython.h:58,
                 from ./CXX/Extensions.hxx:37,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:45,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/char_traits.h:46,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/string:47,
                 from ./CXX/Python3/Exception.hxx:47,
                 from ./CXX/Python3/Objects.hxx:45,
                 from ./CXX/Python3/Extensions.hxx:52,
                 from ./CXX/Extensions.hxx:42,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h: In function ‘int std::__convert_from_v(int* const&, char*, int, const char*, ...)’:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h:77: error: ‘va_start’ was not declared in this scope
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h:85: error: ‘va_end’ was not declared in this scope
lipo: can't figure out the architecture type of: /var/tmp//ccafJH1l.out
error: command 'gcc-4.2' failed with exit status 1
make: *** [mpl_build] Error 1
4

1 に答える 1

7

わかりました... matplotlibを今すぐインストールできるようになりました...

  1. まず、numpyをインストールする必要があります。別の投稿でこれを行うための指示があります:numpyをインストールします

  2. 次に、ターミナルを開き、 matplotlibのgitリポジトリのクローンを作成します(gitがインストールされていることを前提としています)。

    • git clone git://github.com/matplotlib/matplotlib.git(これには時間がかかる場合があります)
  3. クローンが完了したら、Finderでユーザーフォルダを開きます

  4. ユーザーフォルダでmatplotlibディレクトリを開きます

  5. `make.osx'というファイルがありますこれをTextEdit(または同様のもの)で開きます

  6. 次の行を変更します。

    • MACOSX_DEPLOYMENT_TARGET=10.6
    • OSX_SDK_VER=10.6

    に:

    • MACOSX_DEPLOYMENT_TARGET=10.7
    • OSX_SDK_VER=10.7
  7. 次の行を変更します。

    • ${PYTHON} -c 'import urllib; urllib.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'

    に:

    • ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'
  8. 変更を保存します

  9. アイドル状態setupext.pyで呼び出されたファイルを開く

  10. 行を見つけて、次の'darwin' : [],ように変更します'darwin' : ['/usr/local'],

  11. ファイルを保存します

  12. ターミナルを再度開き、次のように入力します。

    • sudo make -f make.osx PREFIX=/usr/local PYVERSION=3.2 fetch deps mpl_build mpl_install
  13. しばらくすると、matplotlibが次のディレクトリにインストールされます。

    • /usr/local/lib/Python3.2/site-packages/
  14. 上記のディレクトリと次のディレクトリを開きます。

    • /Library/Python/3.2/site-packages/
  15. /usr/local/lib/Python3.2/site-packages/次のディレクトリをからにコピー/移動します/Library/Python/3.2/site-packages/

    • dateutil
    • matplotlib
    • mpl_toolkits
  16. matplotlibがインストールされているはずです

  17. アイドル状態を開いて入力import matplotlibしても、エラーは返されません

  18. matplotlib/examples/user_interfaces/embedding_in_qt4_wtoolbar.pyファイルを試してみましたが、問題なく動作しているようです

他の誰かがこれが役立つことを願っています!

助けてくれてありがとう、

アダム。

于 2012-05-13T19:14:32.860 に答える