Mechanize not being installed by easy_install?

妖精的绣舞 提交于 2020-01-24 12:47:44

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1151256/mechanize-not-being-installed-by-easy-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!