安装了Mechanize,但是Python找不到模块

我使用以下命令将机械化安装到目录中:


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。


aluckdog
浏览 199回答 1
1回答

素胚勾勒不出你

我修好了。将home的.bash_profile的第一行设置为# Setting PATH for MacPorts Python# The orginal version is saved in .bash_profile.pysavePATH="/opt/local/bin/python2.7:${PATH}"export PATH并在主目录的.bash_profile中删除了其他版本的Python。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python