macのpythonのインタラクティブシェルで日本語入力できないよ(解決)

今までmacpythonインタラクティブシェル上ではなぜか日本語入力ができなかったので、わざわざスクリプトをファイルに書き込んでそれを実行していました。
面倒臭いですねー。
でも直接日本語入力できる方法を探すことができたのでメモっておきます。


MacPythonインタラクティブシェルを使っているのですが、日本語を打つと以下のようになって入力できません。

回答欄に書かれていたブログのコメントには以下のとおり。


yasuk 2010/04/24 11:31
Mac OS X 10.6.3 では
$ easy_install readline
だけでOKでした。

私の環境は Mac OS X 10.6.4 ですが気にせず実行してみます。


$ easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://www.python.org/
Best match: readline 2.6.4
Downloading http://pypi.python.org/packages/2.6/r/readline/readline-2.6.4-py2.6-macosx-10.6-universal.egg#md5=15ecdee9a7b777b50f7e11d039c8ee75
Processing readline-2.6.4-py2.6-macosx-10.6-universal.egg
creating /Library/Python/2.6/site-packages/readline-2.6.4-py2.6-macosx-10.6-universal.egg
Extracting readline-2.6.4-py2.6-macosx-10.6-universal.egg to /Library/Python/2.6/site-packages
Adding readline 2.6.4 to easy-install.pth file

Installed /Library/Python/2.6/site-packages/readline-2.6.4-py2.6-macosx-10.6-universal.egg
Processing dependencies for readline
Finished processing dependencies for readline

さて、どうでしょうか。


$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print "ほげ"
ほげ
>>>

はい、成功です。
よかった。
今までの苦労がちょっと馬鹿らしくなりますね。

tweepyについて調べるんだ(その2)

インストールとoauth認証twitterAPI用pythonライブラリtweepyを使えるようになるまで。 を読んだらサクっと終りました。
丁寧に書かれてるから気持よく作業ができましたよっ。感謝。

# -*- coding: utf-8 -*-

import tweepy

# 自分の環境にあわせて書き換えるところ
consumer_key = 'MY_CONSUMER_KEY'
consumer_secret = 'MY_CONSUMER_SECRET'
access_key = 'MY_ACCESS_KEY'
access_secret = 'MY_ACCESS_SECRET'

def authenticate():
    """ oauth認証 """
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_key, access_secret)
    return auth

def main():
    """ 主処理 """
    auth = authenticate()
    api = tweepy.API(auth, secure=True)

    api.update_status('hello world')


if __name__ == '__main__':
    main()

これで "hello world" とポストされます。

tweepyについて調べるんだ

pythonからtwitter apiを叩くには python-twitter を使っている事が多いようですが、どうやらoauthには未対応っぽいのです。


8月16日から8月31日の間、毎日APIを呼ぶ回数制限(rate limit)を毎日減らします。(1時間あたり10コールの単位で減らします。) 8月31日からはベーシック認証のAPIコールに対しては全てHTTP 403エラーを返します。

既にカウントダウンが始まっている状況なので、できればoauth認証可能なものを使いたいのが人情というものかなーっと。そこで少し調べてみたら oauth-python-twitter というものが見つかりました。これを使えばpython-twitterでoauthに対応できるようです。

でも調査中に tweepy という別のライブラリを見つけたので、python-twitter&oauth-python-twitterは一旦スルーしてこっちを先に調べようと思います。以下はtweepyのREADMEです。


A Twitter library for Python! Also works with identi.ca/laconi.ca !

Features:
+ OAuth support (including xAuth)
+ Covers the entire Twitter API
+ Actively under development
+ Streaming API support
+ Cache system (memory, file)

Documentation: http://joshthecoder.github.com/tweepy/docs/index.html
Mailing list: http://groups.google.com/group/tweepy
Chat: IRC freenode.net #tweepy
Web interface: http://webchat.freenode.net/?channels=tweepy
Wiki: http://wiki.github.com/joshthecoder/tweepy
Bug tracker: http://github.com/joshthecoder/tweepy/issues

Souce code:
Library: http://github.com/joshthecoder/tweepy
Examples: http://github.com/joshthecoder/tweepy-examples

Author: Joshua Roesslein
License: MIT
Dependencies:
Python 2.4 or newer
Simplejson http://undefined.org/python/#simplejson
**Included in python 2.6+
Python-OAuth http://code.google.com/p/oauth
**Bundled with this library

特徴を訳してみると、

+ OAuth support (including xAuth)
OAuthをサポートしてます(xAuthも含んでいるよ)
+ Covers the entire Twitter API
Twitter APIを全部カバーしてるよ
+ Actively under development
活発に開発してるよ
+ Streaming API support
Streaming APIをサポートしてまっせ
+ Cache system (memory, file)
キャッシュシステム(メモリ、ファイル)もあるんだぜ

「活発に開発してるよ」ってところがなんだか嬉しいですね。

ライセンスは MIT ですね。いいですねー。
依存しているものはPython2.4以上、Simplejson(2.6以上だと最初っから入っているよ)、Python-OAuth(tweepyにバンドルしてるんだ)の3つだけ。いいですねー。

というわけで、次から調べたこと/分かったことなんかを書いていきたいと思います。

Mac OS Xの特殊キーのシンボル「Forward Delete」

Mac OS Xの特殊キー forward delete は "Forward Delete" を意味し、Apple純正キーボードでは fn+delete で入力できます。

出現頻度も少なく、なかなか覚えることができません。


参考

CORESERVER.JPでSSH

Mac OS Xを再インストールしてから一度も接続してなかったCORESERVER
使わないと勿体ない&&久々に遊びたくなったので、とりあえず「Mac OS10.5 LeopardからSSH公開鍵認証でCORESERVERにログイン」を参考にしてSSH接続できるようにしてみました。あっさり成功。前はもうちょっと苦労した気がするんだけどなー。


今日はここまで。

Windows Live Messenger 2009で日本語入力ができなくなる不具合、解決

Windows Live Messenger 2009で日本語入力ができなくなる場合があってイライラする日々を過ごしていたわけですが、既に解決済みの問題だったようなので修正プログラムをあてました。


Windows Live Messengerで日本語入力が出来ないので聞いてみた - まめ畑

http://d.hatena.ne.jp/con_mame/20090114


Windows Live Messenger - 会話ウィンドウ上でかな変換ができない問題について

http://help.jp.msn.com/maintenance.aspx#20090310_Messenger_Kana