wustho / epy

CLI Ebook (epub2, epub3, fb2, mobi) Reader
GNU General Public License v3.0
962 stars 52 forks source link

Error: module curses has no attribute A_ITALIC #40

Open poetaman opened 2 years ago

poetaman commented 2 years ago

When I open a epub or mobi, I get the following error. I have not updated epy in my other machine, this does not happen there. Am using the current version of pip3 while reporting this on my current machine.

❯ epy ~/Desktop/Books/Effective_Writing.epub
Traceback (most recent call last):
  File "/opt/homebrew/bin/epy", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3358, in main
    curses.wrapper(preread, filepath)
  File "/opt/homebrew/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3215, in preread
    reading_state = reader.read(reading_state)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 2501, in read
    text_structure = parse_html(
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 1407, in parse_html
    return parser.get_structured_text(textwidth, starting_line)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 831, in get_structured_text
    attr=curses.A_ITALIC,
AttributeError: module 'curses' has no attribute 'A_ITALIC'
wustho commented 2 years ago

Hello there, current version of epy only supported for python 3.7 or above which support italic in curses and stuff... So really sorry for this, unless you upgrade to latest python, you might need to use older version of epy:

pip install epr-reader==2021.8.14
poetaman commented 2 years ago

@wustho I am using python 3.9.8. I checked that on my system python pointed to version 2.something, so aliased python to python3, but I still get the same error.

Perhaps somewhere in epy-reader, you might want to refer to python3 directly?? I mean change any reference of python to python3?

Update: I opened epy file, it looks like following, so not sure why the error about A_ITALIC.

#!/opt/homebrew/opt/python@3.9/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from epy import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
wustho commented 2 years ago

@reportaman this is weird... I just read your traceback more thoroughly, and it is indeed using correct python version... So as you guessed, the issue is within the epy, it should handle unavailable italic... I will fix it soon... Thanks for detailed traceback btw.

wustho commented 2 years ago

@reportaman Hey there just fixed this in v2021.12.18, you can upgrade it via pip. And let me know if the issue still persists... Thanks