Installing custom packages...
Collecting easyocr
Downloading easyocr-1.7.0-py3-none-any.whl (2.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.9/2.9 MB 36.9 MB/s eta 0:00:00
Collecting tesseract
Downloading tesseract-0.1.3.tar.gz (45.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.6/45.6 MB 52.7 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
Error: Build failed
Retry build
Yeah I just tried with a new app and nearly every version and none of them will build.
The build process (byo packages) is still in beta, so maybe the Anvil staff might know better why this particular library fails, it’s a pretty commonly used library on PyPi .
Probably because in the default (not 3.10 beta) version of Anvil server modules, Pillow 9.0.1 is already installed by the anvil staff into the standard Full Python interpreter:
If tesseract and easyocr are something you really need and they will run in python 3.8, then you could email the staff at support@anvil.works and tell them the use case and the issue with the 3.10 beta and they will get it installed for you usually pretty quick.
Before the 3.10 (Beta), there was only “Full Python 3” like in the list above, and there wasn’t any build process. You can still select “Full Python 3” and it will already have Pillow installed (that link I posted is the big list of everything that’s installed already by Anvil, there is no build process)
In the list it looks like tesseract and easyocr are not installed, but pytesseract and pyocr are.
You can email the staff and ask them to add tesseract and easyocr to “Full Python 3”.
Thanks @ianb PIL is loading up fine now using Full Python3.
However, using an Image object is now failing on a simple jpg or png file:
from PIL import Image
...
image_object = Image.open(image)
Error: 'StreamingMedia' object has no attribute 'read'
This is using the standard FileUploader component. I’m able to use this component successfully to store the image in a data table, but PIL is still causing issues opening the file. I’ve tried using BytesIO as recommended elsewhere to wrap the call but it still throws the same error.
Last thing first, you still use import PIL like normal, Pillow is just a fork of the original PIL library that is no longer maintained (for years). So you don’t change any code, only the name of the library thats installed by pip changes to pip install Pillow instead of PIL.
From looking at the code in the clone of their app this is how @eli originally used PIL in the example link you posted above.
So It looks like our first inclinations were correct, and this was just an issue with the package manager being in beta. It looks like the anvil staff has now fixed the issue with installing Pillow
I tested installing Pillow on a fresh app and it works, if you get an error about security, you can instead install the requests module to a version >= 2.31.0 before installing other packages.