0
import lxml.html

Gives me error when i want to compile with cx_freeze:

   Traceback (most recent call last):
  File "C:\Python27\Scripts\cxfreeze", line 5, in <module>
    main()
  File "C:\Python27\lib\site-packages\cx_Freeze\main.py", line 188, in main
    freezer.Freeze()
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 572, in Freeze
    self._FreezeExecutable(executable)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 186, in _FreezeExecutable
    exe.copyDependentFiles, scriptModule)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 554, in _WriteModules
    path = os.pathsep.join([origPath] + module.parent.path)
TypeError: can only concatenate list (not "NoneType") to list

When i delete this import all is OK, but i need to use lxml.html not importing it solves nothing :(

Nuncjo
  • 1,290
  • 3
  • 15
  • 16

1 Answers1

0

The error you are getting indicates that module.parent.path is returning NoneType. You probably need to make sure that lxml is in your PYTHONPATH.

Mike Vella
  • 10,187
  • 14
  • 59
  • 86
  • What do You mean ? Just add 'C:\Python27\Lib\site-packages\lxml' to PYTHONPATH ? – Nuncjo Sep 03 '13 at 20:30
  • No effect, my PYTHONPATH Looks like this C:\PYTHON27;C:\PYTHON27\DLLs;C:\PYTHON27\LIB;C:\PYTHON27\LIB\LIB-TK;C:\PYTHON27\LIB\SCRIPTS;C:\Python27\Lib\site-packages;C:\Python27\Lib\site-packages\lxml – Nuncjo Sep 03 '13 at 20:47
  • I know it seems like an obvious question but does the code actually successfully import that library when you run it with the python interpreter? – Mike Vella Sep 03 '13 at 20:49
  • Yes, the code is woking i'm using lxml.html to parse websites. The problem occurs during the compilation. I'll restart computer after changes in PYTHONPATH but i must wait few hours to do it, so i will post tommorrow if that solved the problem. – Nuncjo Sep 03 '13 at 20:59
  • This looks like an error in cx_Freeze, not in lxml. I don't have time to debug it now, but try to work out where `module.parent.path` is getting set to None. – Thomas K Sep 03 '13 at 22:42
  • I'm stuck. I tried on other PC with older versions of lxml and cx_freeze and result is the same. Definitely not a problem of PYTHONPATH. – Nuncjo Sep 04 '13 at 19:30
  • Have you had a look at this: http://comments.gmane.org/gmane.comp.python.cx-freeze.user/38 ? Might be relevant, though it's rather old. – Mike Vella Sep 04 '13 at 19:51
  • I didn't find any solution to this problem (tried latest build of cx_freeze too) i just rewriten the code to use lxml.etree and it's working. Problem is with the lxml.html. Suprisingly the same problem exists when i imported requests version 1.2.3 . So cx_freeze seems to be too old to work with new versions of libraries. – Nuncjo Sep 07 '13 at 05:53
  • @MikeJanson glad you found a fix! – Mike Vella Sep 07 '13 at 14:41