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

macOS 10.13 High Sierra - ImportError: pikepdf's extension library failed to import #186

Closed
shashitechno opened this issue Mar 29, 2021 · 13 comments

Comments

@shashitechno
Copy link

shashitechno commented Mar 29, 2021

While using pikepdf along with Django projects its throwing -

ImportError: pikepdf's extension library failed to import. Any ideas if I am missing anything, I did built the qpdf repo as well.

@jbarlow83
Copy link
Member

Lots of things can cause that and it's very platform specific.
See if you can get it to work by installing the pikepdf wheel into an otherwise empty virtual environment, rather than building from source.

@shashitechno
Copy link
Author

shashitechno commented Mar 29, 2021

Are you referring to any specific version or wheel I should try? Thanks for your quick response.

Im running it under OSX, with Ubuntu only pip install works great

@jbarlow83
Copy link
Member

Im running it under OSX, with Ubuntu only pip install works great

I'm not sure what this means. Please tell me what you are trying to get to working that is not working. What OS, install method, processor arch? What steps did you follow?

@shashitechno
Copy link
Author

Operating system - MacOS high Sierra 10.13.3
Processor - 1.8 GHz Intel Core i5
Python version - 3.8

I Installed it as pip install pikepdf the version installed is pikepdf==2.9.2

I also installed qpdf https://github.com/qpdf/qpdf via source installation method!

The error I am getting is -

File "/Users/username/.virtualenvs/cloudpdf/lib/python3.8/site-packages/pikepdf/init.py", line 18, in
raise ImportError(msg) from _e
ImportError: pikepdf's extension library failed to import

I have trying setting up same over an Ubuntu OS and it worked fine, Any thoughts?

@jbarlow83
Copy link
Member

You may have better luck using homebrew to install qpdf rather than build it from source.

Would also be interesting to see if homebrew ocrmypdf works, since ocrmypdf bundles pikepdf.

@shashitechno
Copy link
Author

Tried installing both via brew, it asks me to install via --build-from-source Error: ocrmypdf: no bottle available!

installation goes ok, but then the same error ImportError: pikepdf's extension library failed to import

@cfcurtis
Copy link

cfcurtis commented Apr 3, 2021

I'm having the same issue, also on macOS. This is in an otherwise empty venv where I just did pip install pikepdf.

OS: macOS High Sierra 10.13.6
Processor: 2.26 GHz Intel Core 2 Duo
Python version: 3.9.2
pikepdf version: 2.10.0

A previously created virtual environment works fine with pikepdf version 2.2.0, same python version (installed via homebrew).

@jbarlow83
Copy link
Member

Both of these issues are with High Sierra / 10.13.

Homebrew now only supports 10.13 on a best effort basis, and they'll probably drop 10.14 soon too. I suspect the breakage is in there somewhere.

It may work to do a source build of qpdf and make install it, then source build pikepdf and make sure it can find the source build of qpdf.

pikepdf does request a 10.9 compatible ABI in its build, but that doesn't guarantee it will work.

Bottom line is you'll need to upgrade because third parties are dropping support for 10.13.

@cfcurtis
Copy link

cfcurtis commented Apr 3, 2021

Thanks for the reply. Unfortunately I'm building an app using pyinstaller and many of my users are running older systems, so the older I can support the better. I did some tests and found that pikepdf v2.8.0 works; v2.8.0.post1 does not. I don't know anything about building wheels or github actions, but is it possible this is the culprit?

If this is a #wontfix, that's fine - I can continue using an older version of pikepdf for my mac build.

@jbarlow83 jbarlow83 changed the title ImportError: pikepdf's extension library failed to import macOS 10.13 High Sierra - ImportError: pikepdf's extension library failed to import Apr 3, 2021
@jbarlow83
Copy link
Member

That's good detective work.

It's quite possible moving to GHA and the worker from 10.14 to 10.15 made the difference. Although I don't know specifically why since it implies 10.15 lost the ability to generate 10.13-compatible binaries somehow, or isn't selecting the option that allows it to.

Azure Pipelines still has a 10.14 image but it's deprecated. GitHub Actions has already dropped 10.14, so I can't switch to it (or I would, and it would likely fix this). What it comes down to is, the window is closing for 10.13 support. Not so much #wontfix as #cantfix.

If you can build qpdf and pikepdf from source on your 10.13 machine everything should work. In my opinion if you're packaging for Pyinstaller, it makes more sense to build everything from source rather than rely on wheels.

Use the environment variable QPDF_SOURCE_TREE to point pikepdf at the correct qpdf.

@cfcurtis
Copy link

cfcurtis commented Apr 4, 2021

I understand, I've run into other problems with the obsolescence of my old Mac. I even had to coerce it to upgrade past El Capitan, so I'm running a not-quite-vanilla version of High Sierra anyways. I'll look in to building from source.

@jbarlow83, do you have a PayPal link or something I could use to send you a donation? The sewing community (users of my PDFStitcher app) is very generous and I'd like to send some of the appreciation upstream.

@jbarlow83
Copy link
Member

@cfcurtis Thanks for your generous offer. Please send a contribution to OCRmyPDF, which has a sponsor page set up - I maintain both projects. This is the first time pikepdf has attracted contributions :).

I read my own documentation and re-learned that pikepdf v2.0.0 officially ended compatibility for 10.14. I had forgotten. Support for 10.13 was never actually promised and only worked by fluke.

(I sympathize. I still have a machine I need to move off of 10.14. And you can pry my late 2012 Macbook Pro Retina from my cold dead hands - or at least offer me a truly superior model, because in my opinion Apple hasn't exceeded it in 9 years.)

@workflowsguy
Copy link

I just ran into the same issue trying to use pikepdf on macOS 10.13.6.

Just to document, I was able to work around the problem by using MacPorts, where they have installation packages for both qpdf and pikepdf.

The following steps should do the trick:

  • uninstall the pikepdf Python package
  • install MacPorts
  • install qpdf: sudo port install qpdf
  • install py-pikepdf: sudo port install py-pikepdf

The MacPorts version is a few releases behind. As of this writing, they have pikepdf 8.1.1 while 8.3.0 is the latest.

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

4 participants