Mechanize not recognized by py2exe

Gabriel Genellina gagsl-py2 at
Mon Jul 20 09:50:15 CEST 2009

En Fri, 17 Jul 2009 15:51:11 -0300, Stephen M. Olds <smolds at>  

> I have a Python script that uses Mechanize, and runs fine  
> under the
> interpreter. It was installed using easy_install - and the install  
> seemed to
> indicate it was completed.
> The problem is, when I try to compile it using py2exe while in the  
> folder of the
> script, and using the run line command:
> python py2exe
> I get the warning: "Import error: No Module named mechanize"...
> I checked the environmental path and find the following:
> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program  
> Files (x86)\Python;C:\Python25\Lib\site-packages;C:\Program
> Files (x86)\Common Files\Adobe\AGL

The system PATH is irrelevant here - it's only used by Windows to locate  
the Python executable. I don't see a reason to list  
C:\Python25\Lib\site-packages here.
You're mostly interested in sys.path instead (that is, the 'path'  
attribute in the 'sys' Python module)

> I did a search for mechanize and find an egg file in  
> C:\Python25\Lib\site-packages
> named mechanize-0.1.7b-py2.5.
> Not really understanding the "egg" thing, what do I have here that needs  
> to be
> done?

I'm not an egg expert either, and I try to avoid them as a plague. But I  
*think* you can delete the .egg and re-install it using easy_install with  
the -Z option.

Gabriel Genellina

More information about the Python-list mailing list