Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'base64' has no attribute 'decodestring' #169

Open
ghost opened this issue Nov 24, 2021 · 5 comments
Open

AttributeError: module 'base64' has no attribute 'decodestring' #169

ghost opened this issue Nov 24, 2021 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 24, 2021

Hello!

I've install hocr-tools on both mac and ubuntu and get the same error. All images are jpg and the hocr files were created by tesseract.

I'm wondering if I have the wrong versions of supporting libraries installed.

Traceback (most recent call last):
File "/opt/homebrew/bin/hocr-pdf", line 143, in
export_pdf(args.imgdir, 300)
File "/opt/homebrew/bin/hocr-pdf", line 51, in export_pdf
load_invisible_font()
File "/opt/homebrew/bin/hocr-pdf", line 134, in load_invisible_font
uncompressed = bytearray(zlib.decompress(base64.decodestring(font)))
AttributeError: module 'base64' has no attribute 'decodestring'

Name: hocr-tools
Version: 1.1.1
Name: lxml
Version: 4.6.4
Name: Pillow
Version: 8.4.0
Name: reportlab
Version: 3.6.2

@kba
Copy link
Contributor

kba commented Nov 24, 2021

base64.decodestring has been removed in Python 3.9, it has been deprecated since 3.1 - can you run with a less recent Python version?

Related: #158

@ghost
Copy link
Author

ghost commented Nov 24, 2021

Thank you! I installed python 3.8.12 with pyenv and now it works perfectly... and so fast!

@FriedrichFroebel
Copy link

While using an older Python version might have been the solution, this does not seem to hold true any more, with recent Ubuntu versions shipping Python 3.10 by default and Python 3.11 being available. Adding a corresponding check should be easy enough while retaining compatibility with Python 2 (although this is broken for now: #158 (comment)).

@stweil
Copy link
Collaborator

stweil commented Dec 16, 2022

There is no need to support any Python version before 3.7 (which is the oldest version which is still officially supported). And you are right, the code should be fixed to work with recent Python versions, too.

@FriedrichFroebel
Copy link

This apparently already has been fixed in 2019, but not yet released: d756f75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants