ThomDietrich / miflora-mqtt-daemon

Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼πŸ₯€πŸ‘🌳
MIT License
606 stars 141 forks source link

Add virtual environment to the README setup instructions #175

Closed thicknesss closed 1 month ago

thicknesss commented 1 month ago

Hi, I had to reinstall openhabian op rpi 3b, so choose the latest version based on debian12. but now miflora doesn't run as should be. the error in journalctl -u miflora: mei 19 19:45:41 domoberry python3[867]: Traceback (most recent call last): mei 19 19:45:41 domoberry python3[867]: File "/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 14, in <module> mei 19 19:45:41 domoberry python3[867]: from unidecode import unidecode mei 19 19:45:41 domoberry python3[867]: ModuleNotFoundError: No module named 'unidecode' mei 19 19:45:41 domoberry systemd[1]: miflora.service: Main process exited, code=exited, status=1/FAILURE mei 19 19:45:41 domoberry systemd[1]: miflora.service: Failed with result 'exit-code'. mei 19 19:45:41 domoberry systemd[1]: Failed to start miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon. mei 19 19:45:41 domoberry systemd[1]: miflora.service: Scheduled restart job, restart counter is at 3. mei 19 19:45:41 domoberry systemd[1]: Stopped miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon. so I did run : pip3 install -r requirements.txt manualy (as per previous issues) and got:

error: externally-managed-environment

Γ— This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Should miflora be installed in a virtual enviroment so it doesn't conflict with any other package?

thicknesss commented 1 month ago

I followed the link to http://rptl.io/venv and there it is stated clearly:

IMPORTANT From Bookworm onwards, packages installed via pip must be installed into a Python Virtual Environment using venv. This has been introduced by the Python community, not by Raspberry Pi; see PEP 668 for more details.

ThomDietrich commented 1 month ago

Hey there! I myself am a big fan of python venvs and would support that change. Could you please provide a PR with the relevant steps in the README? Thanks!

thicknesss commented 1 month ago

Hi Thom, This is new to me. Should I clone your repo, make changes is the readme and create a Pull Request?

The openhabian-config repo should be amended to, is this a separate action, or are taking care of that?

ThomDietrich commented 1 month ago

Hey! No worries. Yes you simply go to https://github.com/ThomDietrich/miflora-mqtt-daemon/blob/master/README.md and click on the edit button. That will create a clone and you can commit changes in the next step. After that GitHub will offer you the function to create a Pull Request.

Openhabian is unrelated and you would need to provide the same steps to them. You can open a ticket in the same way and someone might help you to include those changes.

thicknesss commented 1 month ago

PR #176 for README and #177 for template.service