ImportError: No module named mechanize

15,382

Have you checked sys.path in the python shell?

>>> import sys
>>> sys.path
# Returns a list of directories & .egg files

For python to find mechanize, it needs to be in one of the places listed on sys.path. If you know where mechanize was installed, then you can check directly whether it's on sys.path (I'm not sure how to find out where it was installed automagically).

Share:
15,382
User
Author by

User

Internet entrepreneur

Updated on June 04, 2022

Comments

  • User
    User almost 2 years

    I'm using easy_install, and I entered:

    easy_install mechanize
    

    and the last line it returned was:

    Finished processing dependencies for mechanize
    

    Now when I try to:

    import mechanize
    

    I get this error:

    ImportError: No module named mechanize
    

    Any idea what's wrong? Thanks

  • mid_kid
    mid_kid over 10 years
    While this works and is a reasonable solution, I would recommend using the system python installation as long as you don't need separate environments.
  • Mantas Vidutis
    Mantas Vidutis over 10 years
    I disagree. Virtualenv is a requirement for everything short of introductions to programming. The earlier you learn it and start using it, the better. Your system python should only have pip, ipython and virtualenv installed.