Home > Blockchain >  Kivy-Ios / Xcode ImportError: The _imaging extension was built for another version of Pillow or PIL
Kivy-Ios / Xcode ImportError: The _imaging extension was built for another version of Pillow or PIL

Time:04-15

Deploying my Kivy app to iOS using Xcode. Everything works fine outside, only the iPhone Simulator is giving me this issue. The pillow recipe version in toolchain is 8.2 (not sure if I can / how to upgrade the toolchain version to 9.1).

Another stack user (@curiousbird11) had the same issue a few months ago but not yet resolved. Please help & thanks in advance!

Xcode is giving me the following error:

/Users/(my)/Library/Developer/CoreSimulator/Devices/0C30A3E5-1F5A-4671-92D9-2806F50694D6/data/Containers/Bundle/Application/D9338DA3-6EEC-4F8E-987A-F5FA5C485B04/(myapp).app/lib/python3.9/site-packages/PIL/Image.py", line 135, in <module>
raise ImportError(
     
ImportError: The _imaging extension was built for another version of Pillow or PIL:

Core version: 8.2.0
Pillow version: 9.1.0
2022-04-08 19:34:04.916986-0500 (myapp)[95575:896241] Application quit abnormally!
2022-04-08 19:34:04.948859-0500 (myapp)[95575:896241] Leaving

CodePudding user response:

I've figured it out. Some prior context: I was getting a previous error "Xcode - ModuleNotFoundError: No module named 'kivymd'. I found a solution to this on stackoverflow to solve this error by:

"Copy the kivymd package from /usr/local/lib/python3.9/site-packages and paste into kivy-ios/dist/root/python3/lib/python3.9/site-packages"

This solved that issue. However, I unintentionally copied and REPLACED the existing site-packages (instead of just adding them and NOT replacing).

So to solve it, I first uninstalled Pillow 9.1.0 and installed Pillow 8.2.0 (to match the toolchain recipe version). Then copied over the files above in bold, WITHOUT replacing the existing files.

Now my Kivy application is working in the Xcode simulator. Hope this helps someone!

  • Related