わーくあうと!

日々の作業でためになったことをアウトプットすることで自分の成長につながればなと。

pythonにsshモジュール入れる

この記事見て、pythonからsshできれば面白い事できそうだなーと思って、試そうとeasy_installでsshモジュール入れようとしたらエラー出た。

$ sudo easy_install ssh
Searching for ssh
Best match: ssh 1.7.14
Processing ssh-1.7.14-py2.6.egg
ssh 1.7.14 is already the active version in easy-install.pth

Using /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ssh-1.7.14-py2.6.egg
Processing dependencies for ssh
Searching for pycrypto>=2.1,!=2.4
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.amk.ca/python/code/crypto
Reading http://www.pycrypto.org/
Best match: pycrypto 2.6
Downloading https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz
Processing pycrypto-2.6.tar.gz
Running pycrypto-2.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gmy2zc/pycrypto-2.6/egg-dist-tmp-Lky9PJ
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
unable to execute /Developer/usr/bin/clang: No such file or directory
error: Setup script exited with error: command '/Developer/usr/bin/clang' failed with exit status 1

「/Developer/usr/bin/clang」なんて無いらしい。
whichでclangを確認したら「/usr/bin/clang」にあるっぽい。

$ which clang
/usr/bin/clang

pycryptoのsetup.pyは絶対パスでclang実行してるのか。。
ということで適当にシンボリックリンク貼ってみる。

$ ln -s /usr/bin/clang /Developer/usr/bin/clang

これでもう一度「easy_install ssh」実行したら入った。
一応入ってるか確認。

$ python 
Python 2.6.7 (r267:88850, Oct 30 2011, 19:00:25) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.10.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssh
>>> 

問題なくインポートできたから大丈夫そう。