Packing a Scrapy application using Cx_freeze or Py

2019-05-23 02:28发布

问题:

I'm trying to package a web scraping script (built using scrapy) to run as a standalone application for my boss to use. I built a small desktop GUI using Tkinter that calls my Scrapy spiders through an os.system call.

My current build implementation (using cx_Freeze) is below. It successfully packages my program into an .exe that works properly on my machine. However, when I try to port it to another Windows machine and run it, the GUI works but the system calls do not. I figure this is because my current approach requires scrapy to be installed on that machine bc it uses a system call, but I don't really know how to work around that. Would I have more luck using execute from scrapy.cmdline? When I do that I get build errors about scrapystats. Or should I try packaging it using win2exe?

Thanks for your help!

from cx_Freeze import setup, Executable

includes = ['scrapy', 'Tkinter', 'pkg_resources', 'lxml.etree', 'lxml._elementpath']

build_options = {
                'compressed' : True,
                'optimize' : 2,
                'namespace_packages' : ['zope', 'scrapy','Tkinter', 'pkg_resources'],
                'includes' : includes,
                'excludes' : []
                }

executable = Executable(
                        script='main.py',
                        copyDependentFiles=True,
                        includes=includes
                        )

setup(name='Inventory Scraper',
      version='0.1',
      description='Scrapes wine inventories!',
      options= {'build_exe': build_options},
      executables=[executable])