Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install mechanize for Python 2.7?

Tags:

I saved mechanize in my Python 2.7 directory. But when I type import mechanize into the Python shell, I get an error message that reads:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import mechanize
ImportError: No module named mechanize
like image 881
user601828 Avatar asked Feb 03 '11 16:02

user601828


People also ask

How do I download mechanize?

To install for development: git clone https://github.com/python-mechanize/mechanize.git cd mechanize pip3 install -e . To install manually, simply add the mechanize sub-directory somewhere on your PYTHONPATH .

Does mechanize work with Python 3?

unfortunately mechanize only works with Python 2.4, Python 2.5, Python 2.6, and Python 2.7.

What is mechanize in Python?

The mechanize module in Python is similar to perl WWW:Mechanize. It gives you a browser like object to interact with web pages. Here is an example on how to use it in a program.


3 Answers

using pip:

pip install mechanize

or download the mechanize distribution archive, open it, and run:

python setup.py install
like image 85
Corey Goldberg Avatar answered Oct 08 '22 19:10

Corey Goldberg


Try this on Debian/Ubuntu:

sudo apt-get install python-mechanize
like image 26
evedovelli Avatar answered Oct 08 '22 18:10

evedovelli


You need to follow the installation instructions and not just download the files into your Python27 directory. It has to be installed in the site-packages directory properly, which the directions tell you how to do.

like image 32
Daniel DiPaolo Avatar answered Oct 08 '22 18:10

Daniel DiPaolo