[英]Installed Mechanize, but Python can't find module
我使用以下命令将机械化安装到目录中:
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
你能告诉我如何解决这个问题吗?
编辑:我解决了这个问题。 将home的.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。
我修好了 将home的.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。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.