ぴろの狂人日記

2014年から頑張ってブログを継続しようと思います。「継続と習慣」を今年の目標にしたので、頑張って更新を続けようと思います。おいおいはレビューや数学や認知科学などについて記事を書いていければと思っています

Macでpython3の環境構築6---Matplotlibのインストール3---

zlibのインストール

まず、zlibのページ
へアクセスします。
 
 
最新のバージョンをクリックすると、次の画面になります。
 
 
末尾が「.tar.gz」で終わっているものをクリックするとダウンロードが始まります。
 

ダウンロードし解凍すると、zlib-●-●-●というフォルダができます。(●のところはダウンロードしたバージョンによってかわる。)

今回は、zlib-1.2.7をダウンロードしました。

そして次のように打って、カレントディレクトリに移動します。


hiroshi-no-MacBook-Air:~ hiroshi$ cd Downloads     #  「cd Downloads」と打ってreturnを押す。
hiroshi-no-MacBook-Air:Downloads hiroshi$ cd zlib-●-●-●  #      続けて「cd zlib-●-●-●」と打ってreturnを押す。●のところはダウンロードしたバージョンによって違う。


続けて、次のようにコマンドを打ちます。


hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$ ./configure      #  「./configure」と打ってreturnを押す。


そうすると次のような処理が始まります。


Checking for gcc...
Checking for shared library support...
Building shared library libz.1.2.7.dylib with gcc.
Checking for off64_t... No.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.
Looking for a four-byte integer type... Found.
hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$ 


終わったら、続けて


hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$ make      #  「make」と打ってreturnを押す。


とします。
そうすると、次ような処理が走ります。


gcc -O3  -DHAVE_HIDDEN -I. -c -o example.o test/example.c
gcc -O3  -DHAVE_HIDDEN   -c -o adler32.o adler32.c
gcc -O3  -DHAVE_HIDDEN   -c -o crc32.o crc32.c
gcc -O3  -DHAVE_HIDDEN   -c -o deflate.o deflate.c
gcc -O3  -DHAVE_HIDDEN   -c -o infback.o infback.c
gcc -O3  -DHAVE_HIDDEN   -c -o inffast.o inffast.c
gcc -O3  -DHAVE_HIDDEN   -c -o inflate.o inflate.c
gcc -O3  -DHAVE_HIDDEN   -c -o inftrees.o inftrees.c
gcc -O3  -DHAVE_HIDDEN   -c -o trees.o trees.c
gcc -O3  -DHAVE_HIDDEN   -c -o zutil.o zutil.c
gcc -O3  -DHAVE_HIDDEN   -c -o compress.o compress.c
gcc -O3  -DHAVE_HIDDEN   -c -o uncompr.o uncompr.c
gcc -O3  -DHAVE_HIDDEN   -c -o gzclose.o gzclose.c
gcc -O3  -DHAVE_HIDDEN   -c -o gzlib.o gzlib.c
gcc -O3  -DHAVE_HIDDEN   -c -o gzread.o gzread.c
gcc -O3  -DHAVE_HIDDEN   -c -o gzwrite.o gzwrite.c
/usr/bin/libtool -o libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
gcc -O3  -DHAVE_HIDDEN -o example example.o -L. libz.a
gcc -O3  -DHAVE_HIDDEN -I. -c -o minigzip.o test/minigzip.c
gcc -O3  -DHAVE_HIDDEN -o minigzip minigzip.o -L. libz.a
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/adler32.o adler32.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/crc32.o crc32.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/deflate.o deflate.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/infback.o infback.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/inffast.o inffast.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/inflate.o inflate.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/inftrees.o inftrees.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/trees.o trees.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/zutil.o zutil.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/compress.o compress.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/uncompr.o uncompr.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/gzclose.o gzclose.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/gzlib.o gzlib.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/gzread.o gzread.c
gcc -O3  -fPIC -DHAVE_HIDDEN -DPIC -c -o objs/gzwrite.o gzwrite.c
gcc -dynamiclib -install_name /usr/local/lib/libz.1.dylib -compatibility_version 1 -current_version 1.2.7 -O3  -fPIC -DHAVE_HIDDEN -o libz.1.2.7.dylib adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo  -lc
rm -f libz.dylib libz.1.dylib
ln -s libz.1.2.7.dylib libz.dylib
ln -s libz.1.2.7.dylib libz.1.dylib
gcc -O3  -DHAVE_HIDDEN -o examplesh example.o -L. libz.1.2.7.dylib
gcc -O3  -DHAVE_HIDDEN -o minigzipsh minigzip.o -L. libz.1.2.7.dylib
hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$


さらに続けて、


hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$ sudo make install      #    「sudo make install」と打ってreturnを押す。


とします。 すると、パスワードを求められるので、自分のPCへログインするときのパスワードを入力します。入力できているようには見えませんが、入力できているので気にしない。


Password:        #自分のPCのパスワードを入力。そしてreturnを押す。入力できているようには見えないけど、きちんと認識はされています。


パスワードを入力すると、次のような処理が走ります。


cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.1.2.7.dylib /usr/local/lib
chmod 755 /usr/local/lib/libz.1.2.7.dylib
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
hiroshi-no-MacBook-Air:zlib-1.2.7 hiroshi$ 

 

freetype2のインストール(zlibがある状態で)

続いて、freetype2をzlibがある状態でイントール。やること自体は、以前と同じです。
まず。カレントディレクトリに移動。


hiroshi-no-MacBook-Air:~ hiroshi$ cd Downloads        #    「cd Downloads」と打ってreturnを押す。
hiroshi-no-MacBook-Air:Downloads hiroshi$ cd freetype-2.6 2     #     続いて、「cd freetype-2.6 2」と打ってreturnを押す。


そして、続けて次のように打ちます。


hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$ ./configure       #   「./configure」と打ってreturnを押す。



そうすると、また長いですが、次のようになります。


FreeType build system -- automatic system detection

The following settings are used:

  platform                    unix
  compiler                    cc
  configuration directory     ./builds/unix
  configuration rules         ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `/Applications/Xcode.app/Contents/Developer/usr/bin/make' again to build the library,
or `/Applications/Xcode.app/Contents/Developer/usr/bin/make refdoc' to build the API reference (this needs python >= 2.6).

cd builds/unix; \
      CONFIG_SHELL="/bin/sh" \
        /bin/sh ./configure
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for pkg-config... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm
checking the name lister (/usr/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin14.5.0 file names to x86_64-apple-darwin14.5.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin14.5.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking command to parse /usr/bin/nm output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin14.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for rmdir... rmdir
checking for a BSD-compatible install... /usr/bin/install -c
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking size of int... 4
checking size of long... 8
checking whether cpp computation of bit length in ftconfig.in works... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether munmap is declared... yes
checking for munmap's first parameter type... void *
checking for memcpy... yes
checking for memmove... yes
checking gcc compiler flag -ansi to assure ANSI C works correctly... ok, add it to XX_ANSIFLAGS
checking for ZLIB... no
checking for gzsetparams in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for BZIP2... no
checking for BZ2_bzDecompress in -lbz2... yes
checking bzlib.h usability... yes
checking bzlib.h presence... yes
checking for bzlib.h... yes
checking for LIBPNG... no
checking for libpng-config... no
checking for HARFBUZZ... no
configure: creating ./config.status
config.status: creating unix-cc.mk
config.status: creating unix-def.mk
config.status: creating ftconfig.h
config.status: executing libtool commands
configure:

Library configuration:
  external zlib: yes (autoconf test)
  bzip2:         yes (autoconf test)
  libpng:        no
  harfbuzz:      no

make: Nothing to be done for `unix'.

hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$


続いて、またコマンドを打ちます。


hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$ make        #   「make」と打ってreturnを押す。


すると、過去に一度行っているので、特に処理ははしらず次のようなメッセージがでます。


make: Nothing to be done for `all'.
hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$


さらに、続けます。


hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$ sudo make install      #   「sudo make install」と打ってreturnを押す。


すると、またパスワードを求められるので、自分のPCのパスワードを入力します。


Password:       #   何度も繰り返しになりますが、入力されているようには見えませんがきちんと認識はされています。


すると、次のような処理が始まります。


./builds/unix/mkinstalldirs /usr/local/lib                      \
                         /usr/local/lib/pkgconfig            \
                         /usr/local/include/freetype2/config \
                         /usr/local/bin                      \
                         /usr/local/share/aclocal             \
                         /usr/local/share/man/man1
./builds/unix/libtool --mode=install /usr/bin/install -c                             \
                                  /Users/hiroshi/Downloads/freetype-2.6/objs/libfreetype.la /usr/local/lib
libtool: install: /usr/bin/install -c /Users/hiroshi/Downloads/freetype-2.6/objs/.libs/libfreetype.6.dylib /usr/local/lib/libfreetype.6.dylib
libtool: install: (cd /usr/local/lib && { ln -s -f libfreetype.6.dylib libfreetype.dylib || { rm -f libfreetype.dylib && ln -s libfreetype.6.dylib libfreetype.dylib; }; })
libtool: install: /usr/bin/install -c /Users/hiroshi/Downloads/freetype-2.6/objs/.libs/libfreetype.lai /usr/local/lib/libfreetype.la
libtool: install: /usr/bin/install -c /Users/hiroshi/Downloads/freetype-2.6/objs/.libs/libfreetype.a /usr/local/lib/libfreetype.a
libtool: install: chmod 644 /usr/local/lib/libfreetype.a
libtool: install: ranlib /usr/local/lib/libfreetype.a
for P in /Users/hiroshi/Downloads/freetype-2.6/include/freetype.h /Users/hiroshi/Downloads/freetype-2.6/include/ft2build.h /Users/hiroshi/Downloads/freetype-2.6/include/ftadvanc.h /Users/hiroshi/Downloads/freetype-2.6/include/ftautoh.h /Users/hiroshi/Downloads/freetype-2.6/include/ftbbox.h /Users/hiroshi/Downloads/freetype-2.6/include/ftbdf.h /Users/hiroshi/Downloads/freetype-2.6/include/ftbitmap.h /Users/hiroshi/Downloads/freetype-2.6/include/ftbzip2.h /Users/hiroshi/Downloads/freetype-2.6/include/ftcache.h /Users/hiroshi/Downloads/freetype-2.6/include/ftcffdrv.h /Users/hiroshi/Downloads/freetype-2.6/include/ftchapters.h /Users/hiroshi/Downloads/freetype-2.6/include/ftcid.h /Users/hiroshi/Downloads/freetype-2.6/include/fterrdef.h /Users/hiroshi/Downloads/freetype-2.6/include/fterrors.h /Users/hiroshi/Downloads/freetype-2.6/include/ftfntfmt.h /Users/hiroshi/Downloads/freetype-2.6/include/ftgasp.h /Users/hiroshi/Downloads/freetype-2.6/include/ftglyph.h /Users/hiroshi/Downloads/freetype-2.6/include/ftgxval.h /Users/hiroshi/Downloads/freetype-2.6/include/ftgzip.h /Users/hiroshi/Downloads/freetype-2.6/include/ftimage.h /Users/hiroshi/Downloads/freetype-2.6/include/ftincrem.h /Users/hiroshi/Downloads/freetype-2.6/include/ftlcdfil.h /Users/hiroshi/Downloads/freetype-2.6/include/ftlist.h /Users/hiroshi/Downloads/freetype-2.6/include/ftlzw.h /Users/hiroshi/Downloads/freetype-2.6/include/ftmac.h /Users/hiroshi/Downloads/freetype-2.6/include/ftmm.h /Users/hiroshi/Downloads/freetype-2.6/include/ftmodapi.h /Users/hiroshi/Downloads/freetype-2.6/include/ftmoderr.h /Users/hiroshi/Downloads/freetype-2.6/include/ftotval.h /Users/hiroshi/Downloads/freetype-2.6/include/ftoutln.h /Users/hiroshi/Downloads/freetype-2.6/include/ftpfr.h /Users/hiroshi/Downloads/freetype-2.6/include/ftrender.h /Users/hiroshi/Downloads/freetype-2.6/include/ftsizes.h /Users/hiroshi/Downloads/freetype-2.6/include/ftsnames.h /Users/hiroshi/Downloads/freetype-2.6/include/ftstroke.h /Users/hiroshi/Downloads/freetype-2.6/include/ftsynth.h /Users/hiroshi/Downloads/freetype-2.6/include/ftsystem.h /Users/hiroshi/Downloads/freetype-2.6/include/fttrigon.h /Users/hiroshi/Downloads/freetype-2.6/include/ftttdrv.h /Users/hiroshi/Downloads/freetype-2.6/include/fttypes.h /Users/hiroshi/Downloads/freetype-2.6/include/ftwinfnt.h /Users/hiroshi/Downloads/freetype-2.6/include/t1tables.h /Users/hiroshi/Downloads/freetype-2.6/include/ttnameid.h /Users/hiroshi/Downloads/freetype-2.6/include/tttables.h /Users/hiroshi/Downloads/freetype-2.6/include/tttags.h /Users/hiroshi/Downloads/freetype-2.6/include/ttunpat.h ; do                  \
          /usr/bin/install -c -m 644                           \
            $P /usr/local/include/freetype2 ; \
        done
for P in /Users/hiroshi/Downloads/freetype-2.6/include/config/ftconfig.h /Users/hiroshi/Downloads/freetype-2.6/include/config/ftheader.h /Users/hiroshi/Downloads/freetype-2.6/include/config/ftmodule.h /Users/hiroshi/Downloads/freetype-2.6/include/config/ftoption.h /Users/hiroshi/Downloads/freetype-2.6/include/config/ftstdlib.h  /Users/hiroshi/Downloads/freetype-2.6/objs/ftmodule.h  ; do                         \
          /usr/bin/install -c -m 644                                  \
            $P /usr/local/include/freetype2/config ; \
        done
rm -f /usr/local/include/freetype2/freetype/config/*
rmdir /usr/local/include/freetype2/freetype/config
rmdir: /usr/local/include/freetype2/freetype/config: No such file or directory
make: [install] Error 1 (ignored)
rm -f /usr/local/include/freetype2/freetype/*
rmdir /usr/local/include/freetype2/freetype
rmdir: /usr/local/include/freetype2/freetype: No such file or directory
make: [install] Error 1 (ignored)
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h               \
          /usr/local/include/freetype2/config/ftconfig.h
/usr/bin/install -c -m 644 /Users/hiroshi/Downloads/freetype-2.6/objs/ftmodule.h                 \
          /usr/local/include/freetype2/config/ftmodule.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
          /usr/local/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
          /usr/local/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
          /usr/local/lib/pkgconfig/freetype2.pc
/usr/bin/install -c -m 644 /Users/hiroshi/Downloads/freetype-2.6/docs/freetype-config.1 \
          /usr/local/share/man/man1/freetype-config.1

hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$

 

matplotlibのインストール(zlibのある状態で)

でもって、最後に次のようにコマンドを打ちます。


hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$ pip3 install matplotlib       #  「pip3 install matplotlib」と打ってreturnを押す。


そうすると、次のようになります。


You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): matplotlib in /usr/local/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in /usr/local/lib/python3.4/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.0,>=1.5.6 in /usr/local/lib/python3.4/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4 in /usr/local/lib/python3.4/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/local/lib/python3.4/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python3.4/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): nose>=0.11.1 in /usr/local/lib/python3.4/site-packages (from matplotlib)
hiroshi-no-MacBook-Air:freetype-2.6 hiroshi$


以上でとりあえずzlibとfreetype2とmatplotlibのインストールは完了しました。

で、前回と同様に、また次のコードで試してみました。


import networkx as nx

from matplotlib import pyplot

def main() :
 g=nx.Graph()

 g.add_nodes_from(["node","test"])

 g.add_star([1,2,3,4,5])
 g.add_star([6,7,8,9])

 nx.draw(g)

 pyplot.show()

if __name__ == '__main__':
 main()


しかし、結果は前回と変わらず。。。


まあ、いろいろ調べてみたら原因はそこではないようです。