aerkalov/ebooklib

read fail AttributeError: 'NoneType' object has no attribute 'nsmap'

Gaoyongxian666 opened this issue · 2 comments

  File "C:/Users/Gaoyongxian/Documents/GitHub/OpenSearcher/qutils/epub2txt/epub2txt.py", line 7, in process
    book = epub.read_epub(epub_path)
  File "C:\Users\Gaoyongxian\Documents\GitHub\OpenSearcher\venv\lib\site-packages\ebooklib\epub.py", line 1739, in read_epub
    book = reader.load()
  File "C:\Users\Gaoyongxian\Documents\GitHub\OpenSearcher\venv\lib\site-packages\ebooklib\epub.py", line 1397, in load
    self._load()
  File "C:\Users\Gaoyongxian\Documents\GitHub\OpenSearcher\venv\lib\site-packages\ebooklib\epub.py", line 1694, in _load
    self._load_opf_file()
  File "C:\Users\Gaoyongxian\Documents\GitHub\OpenSearcher\venv\lib\site-packages\ebooklib\epub.py", line 1663, in _load_opf_file
    self._load_metadata()
  File "C:\Users\Gaoyongxian\Documents\GitHub\OpenSearcher\venv\lib\site-packages\ebooklib\epub.py", line 1429, in _load_metadata
    nsmap = metadata.nsmap
AttributeError: 'NoneType' object has no attribute 'nsmap'

***选集1.zip

this is my epub file.

I think this might be because you have a typo in your input EPUB. If you check your OPS/fb.opf file in your input EPUB you will notice it has this:

<package version="2.0" unique-identifier="PrimaryID" mlns="http://www.idpf.org/2007/opf">

and I would say instead of "mlns" it should have "xmlns" (did not test it to be honest):

<package version="2.0" unique-identifier="PrimaryID" xmlns="http://www.idpf.org/2007/opf">
  • Aco

@aerkalov hello, do you know how to modify this bug? the file can't be opened, so how should i modify this typo?