Python – Non Egg Install of Mechanize – Py2exe fails the workaround

Non Egg Install of Mechanize – Py2exe fails the workaround… here is a solution to the problem.

Non Egg Install of Mechanize – Py2exe fails the workaround

I racked my brain to install Mechanize in Win7 without much effort. I tried the easy_install–allways-unzip method. easy_install -Z method. Added a .pth file to the site-packages directory. The above combination has been added.

Py2exe does not handle egg files well. If you have this job, please reply.

Thanks – Brad


Some of the links I clicked on were:

Mechanize not being installed by easy_install?

How to install mechanize for Python 2.7?

http://www.daniweb.com/software-development/python/threads/204941

http://www.velocityreviews.com/forums/t691937-re-mechanize-not-recognized-by-py2exe.html

Solution

If you haven’t read it yet, there’s a section about py2exe website about dealing with eggs. py2exe can be tricky without handling egg installation packages. I’ll do one of the following:

  1. Download the mechanize source package, unzip and edit it setup.py to change the zip_safe option to False. Then install mechanize:: from the command line

    python setup.py install
    
  2. Install using pip:

    pip install mechanize
    

    Of course you have to install pip first (easy_install pip). pip installs flat packages by default. (FYI – if you end up using pip on Windows, you need to be aware that it can’t handle python packages that need to be compiled.) Mechanize won’t be a problem, but if you start using it any regularity…)

Apart from the egg issue, I don’t see anything in mechanize’s package structure that suggests that py2exe will have any issues after installation.

Related Problems and Solutions