Windows7 への Python インストールおよび自然言語処のためのモジュール整備
Python のインストール
Windows 7 に Python 開発環境を構築するため,+http://www.python.org/download/ から Python 2.7.2 をダウンロード。(3.2.2 も置いてあるが,2.* と 3.* では Python の仕様が異なるらしい)
- 具体的には Python 2.7.2 Windows Installer (Windows binary -- does not include source) を落としてきて,インストーラに言われるままに標準構成でインストール。
- 結果として,C:\ の直下に Python27 というディレクトリが出来ていた。
easy_installのインストール
easy_install は各種モジュールを容易にインストールするための仕組みである。具体的には,http://pypi.python.org/pypi/setuptools から落とせる setuptools に含まれる。
(ざっと見たところ,setuptools は Python 2.7 までしか対応していないっぽい。)
- setuptools-0.6c11.win32-py2.7.exe を落としてきて,ダブルクリックでインストール完了。
- Python27\Scripts の下に easy_install.exe が置かれる。
自然言語処理関連のモジュール
以下では,numpy や nltk など,自然言語処理に必要なモジュール(および研究に必要な twitter モジュール)のインストールについて述べる(というほど大したものではない。何故なら easy_install が一通りやってくれるから)。
numpy
C:\Python27\Scripts>easy_install.exe numpy Searching for numpy Reading http://pypi.python.org/simple/numpy/ Reading http://numpy.scipy.org Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=17 5103 Reading http://numeric.scipy.org Best match: numpy 1.6.1 Downloading http://pypi.python.org/packages/2.7/n/numpy/numpy-1.6.1.win32-py2.7. exe#md5=30bec16292be262bd78ff1878a7d8953 Processing numpy-1.6.1.win32-py2.7.exe numpy._import_tools: module references __file__ numpy._import_tools: module references __path__ numpy.core.generate_numpy_api: module references __file__ numpy.core.scons_support: module references __file__ numpy.core.setup: module references __file__ numpy.core.setup_common: module references __file__ numpy.core.tests.test_records: module references __file__ numpy.core.tests.test_regression: module references __file__ numpy.distutils.exec_command: module references __file__ numpy.distutils.misc_util: module references __file__ numpy.distutils.npy_pkg_config: module references __file__ numpy.distutils.system_info: module references __file__ numpy.distutils.command.build_src: module references __file__ numpy.distutils.command.scons: module references __file__ numpy.distutils.fcompiler.compaq: module references __file__ numpy.distutils.fcompiler.__init__: module references __file__ numpy.distutils.tests.test_misc_util: module references __file__ numpy.distutils.tests.gen_ext.setup: module references __file__ numpy.doc.__init__: module references __file__ numpy.f2py.diagnose: module references __file__ numpy.f2py.f2py2e: module references __file__ numpy.f2py.setup: module references __file__ numpy.f2py.setupscons: module references __file__ numpy.f2py.tests.test_array_from_pyobj: module references __file__ numpy.f2py.tests.test_assumed_shape: module references __file__ numpy.f2py.tests.test_kind: module references __file__ numpy.f2py.tests.test_mixed: module references __file__ numpy.f2py.tests.test_size: module references __file__ numpy.lib.utils: module references __file__ numpy.lib.utils: module references __path__ numpy.lib.utils: module MAY be using inspect.getsource numpy.lib.utils: module MAY be using inspect.getsourcefile numpy.linalg.tests.test_build: module references __file__ numpy.numarray.util: module references __file__ numpy.testing.noseclasses: module references __file__ numpy.testing.nosetester: module references __file__ numpy.testing.numpytest: module references __file__ numpy.testing.utils: module references __file__ numpy.tests.test_ctypeslib: module references __file__ creating 'c:\users\muto\appdata\local\temp\easy_install-9buyuv\numpy-1.6.1-py2.7 -win32.egg' and adding 'c:\users\muto\appdata\local\temp\easy_install-9buyuv\num py-1.6.1-py2.7-win32.egg.tmp' to it creating c:\python27\lib\site-packages\numpy-1.6.1-py2.7-win32.egg Extracting numpy-1.6.1-py2.7-win32.egg to c:\python27\lib\site-packages Adding numpy 1.6.1 to easy-install.pth file Installing f2py.py script to C:\Python27\Scripts Installing f2py.pyc script to C:\Python27\Scripts Installed c:\python27\lib\site-packages\numpy-1.6.1-py2.7-win32.egg Processing dependencies for numpy Finished processing dependencies for numpy C:\Python27\Scripts>
networkx
C:\Python27\Scripts>easy_install.exe networkx Searching for networkx Reading http://pypi.python.org/simple/networkx/ Reading http://networkx.lanl.gov/ Reading http://networkx.lanl.gov/download/networkx Reading http://sourceforge.net/project/showfiles.php?group_id=122233 Reading http://networkx.lanl.gov/download Reading http://networkx.lanl.gov Reading https://networkx.lanl.gov Best match: networkx 1.5 Downloading http://networkx.lanl.gov/download/networkx/networkx-1.5-py2.7.egg Processing networkx-1.5-py2.7.egg creating c:\python27\lib\site-packages\networkx-1.5-py2.7.egg Extracting networkx-1.5-py2.7.egg to c:\python27\lib\site-packages Adding networkx 1.5 to easy-install.pth file Installed c:\python27\lib\site-packages\networkx-1.5-py2.7.egg Processing dependencies for networkx Finished processing dependencies for networkx C:\Python27\Scripts>
C:\Python27\Scripts>easy_install twitter Searching for twitter Reading http://pypi.python.org/simple/twitter/ Reading http://mike.verdone.ca/twitter/ Best match: twitter 1.6.1 Downloading http://pypi.python.org/packages/2.7/t/twitter/twitter-1.6.1-py2.7.eg g#md5=1f41e3f784e568129c3f3e8a45756805 Processing twitter-1.6.1-py2.7.egg Moving twitter-1.6.1-py2.7.egg to c:\python27\lib\site-packages Adding twitter 1.6.1 to easy-install.pth file Installing twitter-stream-example-script.py script to C:\Python27\Scripts Installing twitter-stream-example.exe script to C:\Python27\Scripts Installing twitter-stream-example.exe.manifest script to C:\Python27\Scripts Installing twitter-script.py script to C:\Python27\Scripts Installing twitter.exe script to C:\Python27\Scripts Installing twitter.exe.manifest script to C:\Python27\Scripts Installing twitterbot-script.py script to C:\Python27\Scripts Installing twitterbot.exe script to C:\Python27\Scripts Installing twitterbot.exe.manifest script to C:\Python27\Scripts Installing twitter-log-script.py script to C:\Python27\Scripts Installing twitter-log.exe script to C:\Python27\Scripts Installing twitter-log.exe.manifest script to C:\Python27\Scripts Installed c:\python27\lib\site-packages\twitter-1.6.1-py2.7.egg Processing dependencies for twitter Finished processing dependencies for twitter C:\Python27\Scripts>
pyyaml
C:\Python27\Scripts>easy_install pyyaml Searching for pyyaml Reading http://pypi.python.org/simple/pyyaml/ Reading http://pyyaml.org/wiki/PyYAML Download error: [Errno 11004] getaddrinfo failed -- Some packages may not be fou nd! Best match: PyYAML 3.10 Downloading http://pypi.python.org/packages/2.7/P/PyYAML/PyYAML-3.10.win32-py2.7 .exe#md5=73309e5fe73d7d84e0af3213b2c957ff Processing PyYAML-3.10.win32-py2.7.exe creating 'c:\users\muto\appdata\local\temp\easy_install-jyvabo\PyYAML-3.10-py2.7 -win32.egg' and adding 'c:\users\muto\appdata\local\temp\easy_install-jyvabo\PyY AML-3.10-py2.7-win32.egg.tmp' to it Moving PyYAML-3.10-py2.7-win32.egg to c:\python27\lib\site-packages Adding PyYAML 3.10 to easy-install.pth file Installed c:\python27\lib\site-packages\pyyaml-3.10-py2.7-win32.egg Processing dependencies for pyyaml Finished processing dependencies for pyyaml C:\Python27\Scripts>