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

[Bug]: ModuleNotFoundError: No module named 'img2pdf' #1471

Closed
2 of 3 tasks
wsshin opened this issue Feb 5, 2025 · 3 comments
Closed
2 of 3 tasks

[Bug]: ModuleNotFoundError: No module named 'img2pdf' #1471

wsshin opened this issue Feb 5, 2025 · 3 comments
Assignees

Comments

@wsshin
Copy link

wsshin commented Feb 5, 2025

What were you trying to do?

I just I installed OCRmyPDF through MacPorts; I indicated Homebrew as a installation platform below because MacPorts is not an option, and I get ModuleNotFoundError: No module named 'img2pdf'. See the traceback below.

To avoid any conflict between MacPorts-installed packages, I uninstalled all the packages by sudo port -fp uninstall installed and then reinstalled ocrmypdf by sudo port install ocrmypdf.

The questionnaire below asks if the Python version is compatible with OCRmyPDF. I didn't install any Python explicitly, but I assume it is installed through MacPorts as a dependency.

How can I resolve this issue? I will appreciate any help!

Where are you installing/running from?

Homebrew

OCRmyPDF version

N/A

What operating system are you working on?

macOS

Operating system details and version

Sonoma 14.7.3

Simple sanity checks

  • Operating system is currently supported by its vendor (not end of life)
  • Python version is compatible with OCRmyPDF
  • This issue is not about a specific input file

Relevant log output

$ ocrmypdf
Traceback (most recent call last):
  File "/opt/local/bin/ocrmypdf", line 5, in <module>
    from ocrmypdf.__main__ import run
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/ocrmypdf/__init__.py", line 10, in <module>
    from ocrmypdf import helpers, hocrtransform, pdfa, pdfinfo
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/ocrmypdf/helpers.py", line 26, in <module>
    import img2pdf
ModuleNotFoundError: No module named 'img2pdf'
@wsshin wsshin added the triage Issue needs triage label Feb 5, 2025
@PratikWayase
Copy link

Hey wsshin, I’d like to work on this. Can you assign it to me?

@jbarlow83
Copy link
Collaborator

This is almost certainly a macports issue, so I am going to close it. If macports identifies an issue that we need to address, then open a new issue with details.

@jbarlow83 jbarlow83 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2025
@github-actions github-actions bot removed the triage Issue needs triage label Feb 5, 2025
@wsshin
Copy link
Author

wsshin commented Feb 7, 2025

I was able to resolve the issue. Looking at a bunch of installation messages generated during sudo port install ocrmypdf, I noticed that the ones related to img2pdf:

--->  Fetching archive for img2pdf
--->  Attempting to fetch img2pdf-0.5.1_0+python312.darwin_any.noarch.tbz2 from https://packages.macports.org/img2pdf
--->  Attempting to fetch img2pdf-0.5.1_0+python312.darwin_any.noarch.tbz2.rmd160 from https://packages.macports.org/img2pdf
--->  Installing img2pdf @0.5.1_0+python312
--->  Activating img2pdf @0.5.1_0+python312
--->  Cleaning img2pdf

This seemed to indicate that the img2pdf module was installed for Python 3.12. In contrast, the error message generated while executing ocrmypdf that I reported above indicated that it was trying to find img2pdf for Python 3.13.

Then I googled "macports img2pdf python313" and arrived this webpage, which indicates that there are several variants of img2pdf. I guessed that img2pdf @0.5.1_0+python312 in the MacPorts installation message meant that it was installing the python312 variant. So, following the instructions here, I installed the python313 variant by

$ sudo port install img2pdf +python313

This solved the issue, and now I ocrmypdf works fine!

Hope this helps people experiencing the same issue. I just filed a MacPorts ticket: https://trac.macports.org/ticket/72013.

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