以下の内容はhttps://takuya-1st.hatenablog.jp/entry/2014/01/12/235809より取得しました。


easy_installをユーザー空間にインストール

Python でMechanizeをインストールしようと、easy_installをしたら、パーミッション・エラー

普通にeasy_installをするとパーミッション・エラーになる。

error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-84672.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Python/2.7/site-packages/

そのままだと、システム空間にインストールしようとしてパーミッションエラーになる。
無理矢理インストールしてもいいけど、、、管理が面倒なので

ユーザー空間にインストールしないとダメだわ。

インストールしたいディレクトリを作る

今回は、mac の標準python が 2.7.5だったのでソレに合わせてホームディレクトリに作った。

mkdir -p ~/.python/2.7.5/site-packages/

このディレクトリにeasy_installします。

環境変数でpytonpath をまず設定する。。

export PYTHONPATH="$(realpath ~/.python/2.7.5/site-packages/):$PYTHONPATH"

設定がうまく行ったら、bashrcに書き足して永続化する。

インストール

以上で準備完了だからインストール

takuya@air:~/Desktop$ easy_install --install-dir ~/.python/2.7.5/site-packages/ mechanize 

インストールできたらチェック

takuya@air:~/Desktop$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
>>>

無事出来ました。




以上の内容はhttps://takuya-1st.hatenablog.jp/entry/2014/01/12/235809より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14