2

I am in the process of migrating from an old Win2K machine to a new and much more powerful Vista 64 bit PC. Most of the migration has gone fairly smoothly - but I did find that I needed to reinstall ALL of my Python related tools.

I've downloaded the mechanize-0.1.11.tar.gz file and ran easy_install to install it. This produced C:\Python25\Lib\site-packages\mechanize-0.1.11-py2.5.egg.

I then ran a python script to test it, and it worked fine under the interpreter. But, when I ran py2exe to compile the script, I get a message that mechanize cannot be found.

I then moved the egg to a new folder, used easy_install to install it - and got every indication that it did install.

But, I still get the same message when trying to use py2exe - that mechanize does not exist!

I did a search for "mechanize" of the entire disk, and get only the 2 egg files as a result. What files should be produced by the install - and where should I expect them to be located?

Obviously, I'm missing something here...any suggestions?

Also, perhaps related, the python I am running is the 32 bit 2.5.4 version...which is what I had before and wanted to get everything working properly prior to installing the 64 bit version - plus, I don't see some of the tools (easy_install & py2exe) which seem to support the 64 bit versions. Is that part of the problem, do I need to install & run the 64-bit version - and will that be a problem for those who run 32-bit PC's when they run my scripts?

2 Answers2

2

There is a note on the py2exe site that it does not work if the source is in egg format:

py2exe does not currently (as of 0.6.5) work out of the box if some of your program's dependencies are in .egg form.

If your program does not itself use setuptools facilities (eg, pkg_resources), then all you need to do is make sure the dependencies are installed on your system in unzipped form, rather than in a zipped .egg.

One way to achieve this is to use the --always-unzip option to easy_install.

Which version are you running? The latest version listed at pypi.python.org is version 0.6.9 but there is no indication I can find if the problem with eggs is fixed in this release.

hughdbrown
  • 47,733
  • 20
  • 85
  • 108
  • I'm using the setuptools-0.6c9.win32-py2.5.exe installer for easy_install. I'v check the py2exe site, see the note you mentioned - and have tried to find a way to install mechanize so it is not an egg...On the Peak page http://peak.telecommunity.com/DevCenter/EasyInstall#command-line-options I see the list of options, tried -Z, no help - then noticed somewhere else it needs to follow "easy_install", NOT the file name...still won't work. I'm at the point where I need to get away from this, clear my mind - far too much information that doesn't seem to correlate... Thanks for the help... –  Jul 20 '09 at 03:19
  • I should point out that I think the problem is with the way easy_install (isn't) installing mechanize - NOT with the py2EXE utility. There is some painfully obvious point of using easy_install that I must be missing. As my wife often said, sometimes it takes a 2x4 - sometimes a slege hammer is called for... –  Jul 20 '09 at 03:40
  • I agree -- get easy_install to install mechanize as py2exe requires it: egg-free. I ran easy_install on mechanize as described and got a package that was not zipped in an egg file. "easy_install --always-unzip mechanize" did the trick. – hughdbrown Jul 20 '09 at 13:36
  • I finally got this to work last night - and it did take the -Z option... What I ended up doing was to remove Python entirely - including the Python25 folder...I then re-installed Python v2.5.4 and easy_install, using the Windows installers. (I used 2.5.4 because that's what I had installed on the own machine - and wanted to get everything working before looking at newer versions)... This was followed with the following (in this order): easy_install -Z ClientForm easy_install -Z configobj easy_install -Z mechanize Worked like a charm! Tested & the exe did exactly what was needed. –  Jul 21 '09 at 17:36
0

As other users suggested as above... I hereby summarize the steps I need to make Mechanize and BeautifulSoup work with py2exe.

Converting .py Files to Windows .exe

Follow instructions in here: py2exe Tutorial

STEP 1

Download py2exe from here… http://sourceforge.net/projects/py2exe/files/ (I am using Python 2.7)

I installed 0.6.9 for Python 2.7

py2exe-0.6.9.win32-py2.7.exe (201KB)

Install it

STEP 2

Try a hello world file.. to make sure all works.. as given in

http://www.py2exe.org/index.cgi/Tutorial

  • Python setup.py install (step 2 on web tutorial)
  • Then use a setup.py (step 3 on web tutorial).

See Issues below for any problems with Modules (under this folder: C:\Python27\Lib\site-packages)

STEP 3

Test the executable file.. in the dist directory.

In summary, when you have problems with modules, make sure you visit the site packages directory.. and see if the full package is there instead of just the .egg file. py2exe cannot make use of just the .egg file (a layman's understanding).

Issues:

Mechanize module was not found by py2exe.. this was due to my first installation of mechanize on my local machine was just an .egg file (mechanize-0.2.5-py2.7.egg.OLD 324KB).. I need to install the full mechanize like this:

easy_install --always-unzip <library_name>

I did that.. then this time mechanize was installed in a folder named mechanize-0.2.5-py2.7.egg (1.1MB).

Also beautifulsoup-3.2.0-py2.7.egg originally the .egg file was 69KB… and after installing with

easy_install -–always-unzip BeautifulSoup

it was installed in a folder named beautifulsoup-3.2.0-py2.7.egg (229KB).

Some instructions in here: http://www.daniweb.com/software-development/python/threads/204941

ihightower
  • 3,093
  • 6
  • 34
  • 49