需要解决 Non Egg Install of Mechanize - Py2exe 失败的问题

发布于 2024-12-04 23:14:58 字数 902 浏览 1 评论 0原文

我绞尽脑汁想在Win7中不加鸡蛋的安装Mechanize。我尝试过 easy_install --allways-unzip 方法。 easy_install -Z 方法。在 site-packages 目录中添加了 .pth 文件。添加了上述内容的组合。

Py2exe 不能很好地处理 Egg 文件。如果您已成功完成此操作,请回复。

谢谢 - Brad


我关注的一些链接是:

Mechanize 没有被 easy_install 安装?

如何为 Python 安装 mechanize 2.7?

http://www.daniweb.com/software-开发/python/线程/204941

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

I have racked my brain on getting Mechanize to install without an egg in Win7. I have tried the easy_install --allways-unzip method. The easy_install -Z method. Added .pth file in the site-packages directory. Added combinations of the above.

Py2exe doesn't play nice with egg files. If you have got this working, please reply.

Thanks - Brad


Some of the links I followed are:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷血 2024-12-11 23:14:58

如果您还没有阅读过,py2exe 网站上有一个关于 处理鸡蛋。我不知道它的效果如何(我从不安装eggs),py2exe 可以无需处理安装的egg软件包就已经足够棘手了。我会执行以下操作之一:

  1. 下载 mechanize 源包,解压缩并编辑其 setup.pyzip_safe 选项更改为 False。然后从命令行安装 mechanize:

    python setup.py install
    
  2. 使用 pip 来执行安装:

    pip install mechanize
    

    当然你必须先安装 pip (<代码>easy_install pip)。 pip 默认情况下平面安装软件包。 (仅供参考 - 如果您最终在 Windows 上使用 pip ,您需要注意它无法处理需要编译的 python 包。Mechanize 不会成为问题,但如果您开始使用它任何规律性...)

除了 egg 问题之外,我在 mechanize 的包结构中看不到任何东西表明 py2exe 在平坦安装后会遇到任何问题。

If you haven't already read it there is a section on py2exe website about dealing with eggs. I don't know how effective it is (I never install eggs), and py2exe can be tricky enough without dealing with an egg installed packages. I would do the one of the following:

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

    python setup.py install
    
  2. use pip to do the install:

    pip install mechanize
    

    Of course you'd have to install pip first (easy_install pip). pip installs packages flat by default. (fyi - if you end up using pip on Windows you need to beware that it can't handle python packages that require compiling. Mechanize won't be a problem, but if it's something you start using with any regularity...)

Other than the egg issue there is nothing that I can see in mechanize's package structure that would indicate that py2exe would have any problems picking it up once it has been installed flat.

素手挽清风 2024-12-11 23:14:58

mechanize 的最后一次安装使用了上面发布的 @markgemmill 的方法 1。

我不断收到日志错误:ImportError:运行我的可执行文件时没有名为检查的模块。

在将检查、日历等添加到 py2exe setup.py 中的 contains[] 后,我意识到我应该也许应该更改我的代码:

    import mechanize
        to
    from mechanize import *

这有效。 py2exe 生成的可执行文件运行!

菜鸟错误。永远学习……布拉德

The last install of mechanize used method 1 from @markgemmill as posted above.

I kept getting a log error: ImportError: No module named inspect when running my executable.

After adding inspect, calendar, etc... to the includes[] in py2exe setup.py, I realized that I should maybe I should change my code from:

    import mechanize
        to
    from mechanize import *

This worked. The executable generated from py2exe runs!

A noob mistake. Always learning... Brad

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文