AppDaemon / appdaemon

:page_facing_up: Python Apps for Home Automation
Other
849 stars 418 forks source link

Numpy 2.0.0 conflicting breaking Plugin HASS #2013

Open MartijnAdriaanse opened 4 months ago

MartijnAdriaanse commented 4 months ago

What happened?

When loading the most recent Pandas package, Numpy 2.0.0 also gets loaded. This breaks the import of HASS. See log file. Workaround of specifying numpy==1.26.4 resolves the issue.

Version

4.4.2

Installation type

Home Assistant add-on

Relevant log output

2024-06-21 11:49:08.013912 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2024-06-21 11:49:08.108065 WARNING AppDaemon: error loading plugin: HASS - ignoring
2024-06-21 11:49:08.108171 WARNING AppDaemon: ------------------------------------------------------------
2024-06-21 11:49:08.109872 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/appdaemon/plugin_management.py", line 140, in __init__
    mod = __import__(full_module_name, globals(), locals(), [module_name], 0)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/appdaemon/plugins/hass/hassplugin.py", line 14, in <module>
    from deepdiff import DeepDiff
  File "/usr/lib/python3.11/site-packages/deepdiff/__init__.py", line 10, in <module>
    from .diff import DeepDiff
  File "/usr/lib/python3.11/site-packages/deepdiff/diff.py", line 18, in <module>
    from deepdiff.helper import (strings, bytes_type, numbers, uuids, times, ListItemRemovedOrAdded, notpresent,
  File "/usr/lib/python3.11/site-packages/deepdiff/helper.py", line 63, in <module>
    np_float_ = np.float_
                ^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.

2024-06-21 11:49:08.110010 WARNING AppDaemon: ------------------------------------------------------------

Relevant code in the app or config file that caused the issue

No response

Anything else?

No response

plesetsk commented 4 months ago

Same

peksuj commented 4 months ago

Same

acockburn commented 4 months ago

Where exactly did you specify Pandas to cause this? Was it in an app?

MartijnAdriaanse commented 4 months ago

I used the GUI within HomeAssistant and a requirements.txt, both leading to the same error related to np.float64 / numpy 2.0.0. incompatibility.

The workaround, so far, completely resolves this issue for me. I specified numpy==1.26.4 in the HA GUI and installed and imported other packages (i.e. scipy and PuLP) without any issues so far.

acockburn commented 4 months ago

Thanks for clarifying, and supplying the workaround. I'll leave this open for a while for other folks to see, I don't see that I can do anything to fix it. Numpy isn't an explicit requirement for AD, it seems to get pulled in by deepdiff, but if I add it to our requirements and pin it I might cause other issues later on when they fix it. Let me know if you see something different I can do to help.

sjur-j commented 4 months ago

I use numpy extensively in appdeamon apps and get the same issue. Tried specifying an older version (numpy==1.26.4) in requirements.txt in the same directory as the appdeamon.yaml file, but this does not help. Can you please advice on how I can use the suggested workaround?

sjur-j commented 4 months ago

IMG_8106

sjur-j commented 4 months ago

I finally figured out where to amend the config in the GUI. See picture in above post. Everything is now working again. Thanks for the tip!

plesetsk commented 4 months ago

Thanks!

ahmadyusuf commented 3 months ago

Thank you very much, I was looking into it for the last few days and couldn't figure out what made my sensors in HA stop working. I used appDaemon as a docker container, specifying the numpy version in the requirements file fixed it as well. I hope the developer will fix it in a future release and then we can revert back the work around.

ahmadyusuf commented 3 months ago

@acockburn

HASS plugin is using the DeepDiff module , which will install numpy as a dependency

appdaemon/plugins/hass/hassplugin.py -> Line 14 -> from deepdiff import DeepDiff

The DeepDiff module is using float_ which was removed in numpy 2.0 release, which caused it to break and hence , also break the HASS plugin

File "/usr/lib/python3.11/site-packages/deepdiff/helper.py", line 63

ahmadyusuf commented 3 months ago

mmm, I can see that it was fixed in the Deepdiff module 10 months ago, so probably our fix should by updating the Deepdiff version rather than downgrading the numpy version

https://github.com/seperman/deepdiff/commit/a8f781d86c317c5dd09879ca16251c544b45129b

ahmadyusuf commented 3 months ago

appDaemon is using deepdiff==6.3.0 NumPy 2.0 support was added in 6.6.0 The latest version is v 7.0.1

So we probably need to update to at least 6.6.0 to fix this isuse

fboundy commented 2 months ago

An alternative fix seems to be to specify deepdiff>7.0.0 in the appdaemon config. Appdaemon complains but loads OK

acockburn commented 2 months ago

Thanks for the research - we will update the deepdiff version and see how that works out.


From: fboundy @.> Sent: Thursday, August 15, 2024 10:36 AM To: AppDaemon/appdaemon @.> Cc: Andrew Cockburn @.>; Mention @.> Subject: Re: [AppDaemon/appdaemon] Numpy 2.0.0 conflicting breaking Plugin HASS (Issue #2013)

An alternative fix seems to be to specify deepdiff>7.0.0 in the appdaemon config. Appdaemon complains but loads OK

— Reply to this email directly, view it on GitHubhttps://github.com/AppDaemon/appdaemon/issues/2013#issuecomment-2291407776, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLE7JH5OP7NOSA3SHOBXDDZRS4GPAVCNFSM6AAAAABJVSOESKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJRGQYDONZXGY. You are receiving this because you were mentioned.Message ID: @.***>

acockburn commented 2 months ago

OK, I bumped deepdiff to 7.0.1 in dev - can anyone let me know if this fixes the issue?

dekiesel commented 1 month ago

Just wanted to mention that adding matplotlib also can lead to this error. Adding deepdiff>7.0.0 fixes the issue.

acockburn commented 1 month ago

Thanks - without actually checking I believe we just updated dev to 8.0.0 so we should be past this when the next version of AD releases in a few weeks