鳳鳴は祖父の俳号

日記 メモ そんなの

MacOSXでのpyparsing.pyインストール

 python自体はhomebrewでインストール。

$ brew nstall python

==> Installing dependencies for python: sqlite, gdbm
==> Installing python dependency: sqlite
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/sqlite-3.8.1.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.8.1.mountain_lion.bottle.tar.gz
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/sqlite/lib
CPPFLAGS: -I/usr/local/opt/sqlite/include

==> Summary
🍺 /usr/local/Cellar/sqlite/3.8.1: 9 files, 2.0M
==> Installing python dependency: gdbm
==> Downloading http://ftpmirror.gnu.org/gdbm/gdbm-1.10.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gdbm/1.10 --mandir=/usr/local/Cellar/gdbm/1.10/share/man --infodir=/usr/local/Cellar/gdbm/1.10/share/info
==> make install
🍺 /usr/local/Cellar/gdbm/1.10: 11 files, 244K, built in 25 seconds
==> Installing python
==> Downloading http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/python/2.7.5 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.5/share --datadir=/usr/local/Cellar/python/2.7.5/share --enable-framework=/usr/local/Cellar/python/2.7.5/Frameworks --without-gcc CFLAGS=-I/usr/local/inclu
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.5
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.5/share/python
==> Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-1.1.7.tar.gz
######################################################################## 100.0%
==> /usr/local/Cellar/python/2.7.5/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.5/bin --install-lib=/usr/local/lib/python2.7/site-packages
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz
######################################################################## 100.0%
==> /usr/local/Cellar/python/2.7.5/bin/python -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/2.7.5/bin --install-lib=/usr/local/lib/python2.7/site-packages
==> Caveats
Python demo
/usr/local/share/python/Extras

Setuptools and Pip have been installed. To update them
pip install --upgrade setuptools
pip install --upgrade pip

To symlink "Idle" and the "Python Launcher" to ~/Applications
`brew linkapps`

You can install Python packages with (the outdated easy_install or)
`pip install `

They will install into the site-package directory
/usr/local/lib/python2.7/site-packages

See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
Warning: Could not link python. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link python'

Possible conflicting files are:
/usr/local/bin/smtpd2.7.py -> /Library/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.7.py
/usr/local/bin/pydoc2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
/usr/local/bin/idle2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7
/usr/local/bin/2to3-2.7 -> /Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7
==> Summary
🍺 /usr/local/Cellar/python/2.7.5: 5200 files, 80M, built in 3.4 minutes

$ python --version
Python 2.7.2

 なんかエラーがおきてリンクが置き換わっていない。

$ brew link python
/python/2.7.5... Warning: Could not link python. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/python/2.7.5/bin/smtpd2.7.py
Target /usr/local/bin/smtpd2.7.py already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name

To list all files that would be deleted:
brew link --overwrite --dry-run formula_name

--overwriteオプションをつけろ、と。

$ brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.5... 34 symlinks created

いったんログアウトして確認:
$ python --version
Python 2.7.5


次にpyparsing.pyのインストール。以下からpypersing-2.0.1.zipをダウンロードし、展開。
Python parsing module download | SourceForge.net

$ sudo python setup.py install
Password:
running install
running build
running build_py
running install_lib
copying build/lib/pyparsing.py -> /usr/local/lib/python2.7/site-packages
byte-compiling /usr/local/lib/python2.7/site-packages/pyparsing.py to pyparsing.pyc
running install_egg_info
Writing /usr/local/lib/python2.7/site-packages/pyparsing-2.0.1-py2.7.egg-info
$

確認:
$ cd examples
$ python greeting.py
('Hello, World!', '->', (['Hello', ',', 'World', '!'], {}))
$

PyPy の紹介