问题
My python version is: Python 2.7 I did an easy_install mechanize then I tried running a script and I'm getting this:
File "test.py", line 2, in <module>
import mechanize
ImportError: No module named mechanize
If you need any other information let me know.
回答1:
Try this in case pip or easy_install, for whatever reason, aren't working:
Download the source code from http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz
Unzip the package, go to the command line, change into the folder that was extracted and type:
python setup.py install
If you're on Linux/Mac, you may need to type the following:
sudo python setup.py install
回答2:
Would like to add something for some future users:
In case some of the users get the error "No module named '_version'" Mechanize however doesn't support Python 3 so you should install a Python 2.x release (the latest available is 2.7.3), install the mechanize package there and then retry running your script.
来源:https://stackoverflow.com/questions/14543213/python-mechanize-module-not-found