bimmerconnected / bimmer_connected

🚘 Library to query the status of your BMW or Mini from the ConnectedDrive portal
Apache License 2.0
365 stars 79 forks source link

Pillow Import issue #579

Closed rikroe closed 10 months ago

rikroe commented 11 months ago

Hello,

I would like to use bimmer_connected on my Raspberry Pi 3B+ but I am can't unitl now. I tried to use the latest python version 3.12.0 but there was an installation error from dependant project. Then I tried Python 3.11.5 (because with this version it is running on my Windows 11 PC). Installation on Raspberry was fine but when I run "from bimmer_connected.account import MyBMWAccount" there is the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/pi/.local/lib/python3.11/site-packages/bimmer_connected/account.py", line 10, in <module> from bimmer_connected.api.authentication import MyBMWAuthentication File "/home/pi/.local/lib/python3.11/site-packages/bimmer_connected/api/authentication.py", line 18, in <module> from bimmer_connected.api.utils import ( File "/home/pi/.local/lib/python3.11/site-packages/bimmer_connected/api/utils.py", line 21, in <module> from PIL import Image File "/home/pi/.local/lib/python3.11/site-packages/PIL/Image.py", line 82, in <module> from . import _imaging as core ImportError: libtiff.so.6: cannot open shared object file: No such file or directory

Does someone have an idea what is wrong? Or which Python version on Raspberry Pi is running fine with bimmer_connected?

Thanks for any ideas

_Originally posted by @hube-mic in https://github.com/bimmerconnected/bimmer_connected/discussions/578_

subtrEM commented 10 months ago

FWIW, observed this behavior: bimmer_connected 0.14.1 and beyond installs Pillow (python imaging library) per requirements. Running bimmerconnected from CLI gives errors, missing components. Pillow implicitly requires specific (older) versions: libopenjp2-7, libtiff5 (is Pillow still maintained?). Installing these packages lets the CLI version run.

rikroe commented 10 months ago

Are you also running an RPI 3B+? armhf or armv8a?

hube-mic commented 10 months ago

How do I find out armhf or armv8a? It is a 3B+ image

subtrEM commented 10 months ago

Are you also running an RPI 3B+? armhf or armv8a?

Raspbian Bullseye on raspi 3B (ARMv7); bimmer_connected 0.14.2

rikroe commented 10 months ago

Pillow is still maintained and works with new Python versions: https://pillow.readthedocs.io/en/stable/installation.html Please try installing the required libraries via apt-get install python3-pil. It might be that those are not included in the default images for Raspbian.

@gerard33 @Yixi: Should we maybe make the pillow library optional (i.e. not installed by default)? For HA, we still could still include it (as it shipped with HA anyway), but for command line usage it is not necessarily needed. For chinese accounts, we could raise a specific error message if Pillow is unavailable before first try to login.

hube-mic commented 10 months ago

apt-get install python3-pil did not help. Nothing to update. Seems already to be installed.

hube-mic commented 10 months ago

This is the error message when I try to install bimmerconnected with Python 3.12 image Related to pillow, too. But I am not sure if it is the same root cause

rikroe commented 10 months ago

Please provide the output of uname -m. My current guess is that you're running Raspbian OS 32bit where no wheel (i.e. pre-defined builds) of Pillow are available for. Only arm64/aarch64 is directly built.

Please try installing all required build libraries (taken from https://pillow.readthedocs.io/en/stable/installation.html#external-libraries / Ubuntu).

sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
    libharfbuzz-dev libfribidi-dev libxcb1-dev
Yixi commented 10 months ago

Pillow is still maintained and works with new Python versions: https://pillow.readthedocs.io/en/stable/installation.html Please try installing the required libraries via apt-get install python3-pil. It might be that those are not included in the default images for Raspbian.

@gerard33 @Yixi: Should we maybe make the pillow library optional (i.e. not installed by default)? For HA, we still could still include it (as it shipped with HA anyway), but for command line usage it is not necessarily needed. For chinese accounts, we could raise a specific error message if Pillow is unavailable before first try to login.

I think it's fine, currently Pillow is only used in China to handle captcha's.

gerard33 commented 10 months ago

Pillow is still maintained and works with new Python versions: https://pillow.readthedocs.io/en/stable/installation.html Please try installing the required libraries via apt-get install python3-pil. It might be that those are not included in the default images for Raspbian. @gerard33 @Yixi: Should we maybe make the pillow library optional (i.e. not installed by default)? For HA, we still could still include it (as it shipped with HA anyway), but for command line usage it is not necessarily needed. For chinese accounts, we could raise a specific error message if Pillow is unavailable before first try to login.

I think it's fine, currently Pillow is only used in China to handle captcha's.

I am fine with it as well.

hube-mic commented 10 months ago

Please provide the output of uname -m. My current guess is that you're running Raspbian OS 32bit where no wheel (i.e. pre-defined builds) of Pillow are available for. Only arm64/aarch64 is directly built.

Please try installing all required build libraries (taken from https://pillow.readthedocs.io/en/stable/installation.html#external-libraries / Ubuntu).

sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
    libharfbuzz-dev libfribidi-dev libxcb1-dev

uname -m results in armv71

Installing the packages result in this message (sorry for the german screenshot, I enter below the last message so you can copy to translator if required. image Die folgenden Pakete haben unerfüllte Abhängigkeiten: libtiff5-dev : Hängt ab von: libtiff-dev (>= 4.0.10-1) soll aber nicht installiert werden E: Probleme können nicht korrigiert werden, Sie haben zurückgehaltene defekte Pakete.

rikroe commented 10 months ago

Other than waiting for https://github.com/bimmerconnected/bimmer_connected/pull/583 (or replacing the 32bit OS with 64bit) I have no other idea, sorry. This is a really nice dependency hell on linux packages for old architectures.

rikroe commented 10 months ago

Please try installing 0.14.4 as you would do normally - it should work now.

hube-mic commented 10 months ago

Thanks a lot for your support. With Python 3.11 it is working now :-) With Python 3.12 I have still the same installation error for pillow mentioned here: https://github.com/bimmerconnected/bimmer_connected/issues/579#issuecomment-1821425898

rikroe commented 10 months ago

Please make sure that all installations of bimmer-connected are removed first. It sound as if you have an older version installed somewhere.

hube-mic commented 10 months ago

How can I check it? With help("modules") there is no bimmer_connected.

I have my solution with python 3.11 and do not expect further help here. Just to know for you that there is maybe an issue with python 3.12 on Raspberry PI and I can help/test if you want.