Dragon2fly / xlrd3

Other
9 stars 5 forks source link

xlrd3 error opening xlsx for read #6

Closed redobbin closed 9 months ago

redobbin commented 9 months ago
  1. I have a script that is using xlrd3 to read an excel workbook (inherited the code).
  2. I have made changes to update it where it will accept xlsx files and it work if running the script at the command prompt in terminal. It also works without issue in Visual Studio Code.
  3. When I run pyinstaller to create an executable fails, with the following errors:
Traceback (most recent call last):
  File "ccdiff.pyw", line 418, in <module>
  File "ccdiff.pyw", line 272, in main
  File "xlrd3/__init__.py", line 112, in open_workbook
  File "xlrd3/xlsx.py", line 846, in open_workbook_2007_xml
  File "xlrd3/xlsx.py", line 41, in ensure_elementtree_imported
Exception: Failed to import an ElementTree implementation
[71116] Failed to execute script 'ccdiff' due to unhandled exception: Failed to import an ElementTree implementation
[71116] Traceback:
Traceback (most recent call last):
  File "ccdiff.pyw", line 418, in <module>
  File "ccdiff.pyw", line 272, in main
  File "xlrd3/__init__.py", line 112, in open_workbook
  File "xlrd3/xlsx.py", line 846, in open_workbook_2007_xml
  File "xlrd3/xlsx.py", line 41, in ensure_elementtree_imported
Exception: Failed to import an ElementTree implementation

Environment:

macOS 13.6 Python 3.12.0

Package Version


altgraph 0.17.4 bottle 0.12.25 bottle-websocket 0.2.9 easygui 0.98.3 Eel 0.16.0 et-xmlfile 1.1.0 future 0.18.3 gevent 23.9.1 gevent-websocket 0.10.1 greenlet 3.0.0 macholib 1.16.3 packaging 23.2 pip 23.3 pyinstall 0.1.4 pyinstaller 6.1.0 pyinstaller-hooks-contrib 2023.10 pyparsing 3.1.1 setuptools 68.2.2 six 1.16.0 treelib 1.7.0 whichcraft 0.6.1 xlrd3 1.1.0 xlwt 1.3.0

Dragon2fly commented 9 months ago

Hi @redobbin

xlrd3 imports implicitly one of the following libs with descending priority: defusedxml, lxml, xml.

So you have to explicitly tell pyinstaller to include at least one of the above: --hidden-import [lib_name] Since you didn't use any 3rd library to parse XML, then [lib_name] is just xml. If you care about security and speed, use the other two.

redobbin commented 9 months ago
Many thanks, I will use the other two as suggested. --robert  From: Dragon2flySent: Thursday, October 19, 2023 08:49To: Dragon2fly/xlrd3Cc: redobbin; MentionSubject: Re: [Dragon2fly/xlrd3] xlrd3 error opening xlsx for read (Issue #6) Hi @redobbinxlrd3 import implicitly one of the following libs: defusedxml, lxml, xml.So you have to explicitly tell pyinstaller to include at lease one of the above: --hidden-import [lib_name]Since you didn't use any 3rd library to parse XML, then [lib_name] is just xml.If you care about security and speed, use the other two.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>