用py2exe制作Scrapy应用程序

时间:2014-05-12 14:23:24

标签: python python-2.7 web-scraping scrapy py2exe

我尝试使用py2exe将带有自定义GUI的Scrapy蜘蛛打包到Windows可执行文件中。 GUI从外部脚本调用spider。直接从Python脚本运行时,这一切都正常。使用py2exe打包时遇到错误。这与问题posted here非常相似,但使用py2exe而不是cx_freeze。我试图使用cx_freeze关注该帖子和包,但我仍然收到相同的错误。下面是我正在使用的py2exe setup.py:

from distutils.core import setup
import py2exe

includes = ['scrapy', 'os', 'twisted']
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
        'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
        'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
            'tk84.dll']

setup(
    options = {"py2exe": {"compressed": 2, 
                      "optimize": 2,
                      "includes": ['lxml.etree', 'lxml._elementpath', 'gzip'],
                      "excludes": excludes,
                      "packages": packages,
                      "dll_excludes": dll_excludes,
                      "bundle_files": 3,
                      "dist_dir": "dist",
                      "xref": False,
                      "skip_archive": False,
                      "ascii": False,
                      "custom_boot_script": '',
                     }
          },
    windows=['ItemStatusChecker.py']
)

所有内容都正常编译,但在运行exe文件时,我收到以下错误:

Traceback (most recent call last):
  File "ItemStatusChecker.py", line 92, in OnButtonClicked
    crawler = Crawler(settings)
  File "scrapy\crawler.pyo", line 20, in __init__
  File "scrapy\utils\misc.pyo", line 42, in load_object
ImportError: Error loading object 'scrapy.statscol.MemoryStatsCollector': No module named statscol

我可以在setup.py中为py2exe做些什么来确保将完整的包拉入我的应用程序并且我可以访问所有功能(类似于上面链接的帖子中找到的解决方案)?

0 个答案:

没有答案