Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyscript won't load with HASS 2023.08.01 #510

Open
tal opened this issue Aug 9, 2023 · 5 comments
Open

Pyscript won't load with HASS 2023.08.01 #510

tal opened this issue Aug 9, 2023 · 5 comments

Comments

@tal
Copy link

tal commented Aug 9, 2023

Seems like it's unable to handle the new event type of entity:

This error originated from a custom integration.

Logger: homeassistant.setup
Source: custom_components/pyscript/__init__.py:27
Integration: pyscript (documentation, issues)
First occurred: 6:34:44 PM (1 occurrences)
Last logged: 6:34:44 PM

Setup failed for custom integration pyscript: Unable to import component: cannot import name 'Event' from 'homeassistant.helpers.event' (/usr/src/homeassistant/homeassistant/helpers/event.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/pyscript/__init__.py", line 27, in <module>
    from homeassistant.helpers.event import Event as HAEvent
ImportError: cannot import name 'Event' from 'homeassistant.helpers.event' (/usr/src/homeassistant/homeassistant/helpers/event.py)
@craigbarratt
Copy link
Member

Duplicates #500, #501, #502, #504, #505. Upgrade to pyscript 1.5.0.

@r0oland
Copy link

r0oland commented Aug 11, 2023

I am on Home Assistant 2023.8.1 running in a Docker Container and using pyscript 1.5.0 and I am still having issues:

[homeassistant.setup] Setup failed for custom integration pyscript: Unable to import component: cannot import name 'Event' from 'homeassistant.helpers.event' (/usr/src/homeassistant/homeassistant/helpers/event.py)

The relevant part of the log can be found attached.

I have restarted everything, pulled the latest Docker container and reinstalled pyscript, all with no effect. Any suggestions on what to try?

home-assistant_2023-08-11T06-15-51.953Z.log

@craigbarratt
Copy link
Member

craigbarratt commented Aug 11, 2023

You do say you are running 1.5.0, but I just can't see how that error could happen with 1.5.0. Is there any chance you are not really running 1.5.0? Can you check the installed code in custom_components/pyscript/manifest.json? Also, in custom_components/pyscript/__init__.py, do you see a line like this:

from homeassistant.core import Event as HAEvent

If you see that code, then you are running 1.5.0.

@r0oland
Copy link

r0oland commented Aug 11, 2023

EDIT:

I am sorry...of course the error was on my side, but looking at the custom components folder as per your instructions helped me find the mistake...

For some reason, there were two copies of pyscript in the custom components directory:

  • "pyscript"
  • "pyscript_old"

For some reason it would automatically pick the old one...

After deleting that things seem to be running normally...

@craigbarratt
Copy link
Member

craigbarratt commented Aug 11, 2023

Yes, that is 1.5.0.

However, from the log file, you can see the error is coming from this file: /config/custom_components/pyscript_old/__init__.py, which presumably is an old version, I would guess manually copied?

Edit - I wrote and posted this before I saw your confirmation. Glad the problem is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants