python - What's needed to get BeautifulSoup4+lxml to work with cx_freeze? -


summary:

i have wxpython/bs4 app i'm building exe cx_freeze.

there build succeeds no errors, trying run exe results featurenotfound error beautifulsoup4. it's complaining don't have lxml library installed.

i've since stripped program down it's minimal state , still error.

has else had success building bs4 app cx_freeze?

please take @ details below , let me know of ideas may have.

thanks,


details

full error traceback:

i've simplified app it's basic state , still error. same error on python 3.4.

traceback (most recent call last):   file "c:\winpython27\python-2.6.7\lib\site-packages\cx_freeze\initscripts\console.py", line 27, in <module>     exec(code, m.__dict__)   file "test.py", line 6, in <module>   file "c:\winpython27\python-2.6.7\lib\site-packages\bs4\__init__.py", line 152, in __init__     % ",".join(feautres)) featurenotfound: couldn't find tree builder features requested: xml. need install parser library? 

what i've tried:

i found people saying need include lxml , it's dependents in build script: http://sourceforge.net/p/cx-freeze/mailman/message/27973651/ (sorry sf link). tried this, still no dice.

commenting out line soup = beautifulsoup("<tag>value</tag>", 'xml') results in no errors.


versions , files:

versions:

  • lxml 3.4.4
  • beautifulsoup4 4.3.2
  • python 2.7.6 (32bit) , python 3.4.3 (64bit)
  • cx_freeze 4.3.4
  • wxpython 3.0-msw
  • windows 7 professional sp1, 64-bit

test.py

this file simplified app still gets error.

# -*- coding: utf-8 -*- __future__ import print_function bs4 import beautifulsoup import wx  soup = beautifulsoup("<tag>value</tag>", 'xml')  app = wx.app() frame = wx.frame(none, wx.id_any, "test frame") frame.show() app.mainloop() 

build_executables.py

this (simplified) build script using.

# -*- coding: utf-8 -*- cx_freeze import setup, executable build_exe_opts = {"silent": false, }  base = "win32gui"  exes_to_build = [executable("test.py", base=base),                  ]  setup(     name="test",     version="0.0.1",     description="fti test program editor , diff tool.",     options={"build_exe": build_exe_opts},     executables=exes_to_build, ) 

cx_freeze log

i'm not going include entire log here, did run python build_executables.py build >> c:\temp\build_log.txt can that's asked for.

here lines contain 'lxml' in them:

  name                      file   ----                      ---- p bs4                       c:\winpython27\python-2.7.6\lib\site-packages\bs4\__init__.py p bs4.builder               c:\winpython27\python-2.7.6\lib\site-packages\bs4\builder\__init__.py m bs4.builder._html5lib     c:\winpython27\python-2.7.6\lib\site-packages\bs4\builder\_html5lib.py m bs4.builder._htmlparser   c:\winpython27\python-2.7.6\lib\site-packages\bs4\builder\_htmlparser.py m bs4.builder._lxml         c:\winpython27\python-2.7.6\lib\site-packages\bs4\builder\_lxml.py m bs4.dammit                c:\winpython27\python-2.7.6\lib\site-packages\bs4\dammit.py m bs4.element               c:\winpython27\python-2.7.6\lib\site-packages\bs4\element.py ... p lxml                      c:\winpython27\python-2.7.6\lib\site-packages\lxml\__init__.py m lxml.etree                c:\winpython27\python-2.7.6\lib\site-packages\lxml\etree.pyd ... copying c:\winpython27\python-2.7.6\lib\site-packages\lxml\etree.pyd -> build\exe.win32-2.7\lxml.etree.pyd 

the build succeeds no errors.

after investigation, going bs4 , builders, found need add gzip.

so in end, cx_freeze script needs, @ minimum, these packages added when building exe bs4 + lxml: lxml , gzip.

so build_executables.py script should like:

# -*- coding: utf-8 -*- cx_freeze import setup, executable build_exe_opts = {"silent": false,                   "packages": ['lxml', 'gzip'],                   } base = "win32gui"  exes_to_build = [executable("test.py", base=base)]  setup(     name="test",     version="0.0.1",     description="blah blah blah",     options={"build_exe": build_exe_opts},     executables=exes_to_build, ) 

and when run python build_executables.py build , try executable, should work.


Comments