次を使用して、mechanizeをディレクトリにインストールしました。
sudo easy_install --always-unzip mechanize
Searching for mechanize
Best match: mechanize 0.2.5
Processing mechanize-0.2.5-py2.7.egg
mechanize 0.2.5 is already the active version in easy-install.pth,
しかし、スクリプト Scrape.py を呼び出すと、次のエラーが発生します。
Traceback (most recent call last):
File "scrape.py", line 6, in <module>
from mechanize import Browser
ImportError: No module named mechanize
Mac OSX 10.8 (10.6 から) にアップグレードする前にこのスクリプトを使用し、Java Ant をいじりました。ここに私の道があります:
echo $PATH
/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/ant/bin
これを修正する方法を教えていただけますか?
編集:これを修正しました。ホームの .bash_profile の最初の行を
# Setting PATH for MacPorts Python
# The orginal version is saved in .bash_profile.pysave
PATH="/opt/local/bin/python2.7:${PATH}"
export PATH
ホームディレクトリの .bash_profile にある他のバージョンの Python を削除しました。