Closed xenia-09A closed 3 months ago
import requests
@service
def hello_workd():
pass
@ALERTua
@ALERTua thank you so much !!! that helped having import above @service thanks gosh I feel stupid!! script now shows up in dev tools!
please close this issue if you have no further questions :)
again thanks for the help .. I am having an issue seeing anything in logs but I keep at it I now have this:
import requests @service
def hello_world():
url = "https://raw.githubusercontent.com/custom-components/pyscript/master/README.md"
resp = task.executor(requests.get, url)
log.info(f"Hello World")
log.info(resp.text)
closing a simple reboot of HA resolved @ALERTua thanks again
thanks
Hi, I'm struggling to get import working in pyscript via HACS on HA 2024.7.1. any python file without an import works fine and I can run as service and show up in dev tools
then i simply add import requests for example I get this:
Exception in </config/pyscript/hello_world.py> line 2: i ^ SyntaxError: invalid syntax (hello_world.py, line 2) Exception in </config/pyscript/hello_world.py> line 2: import requests ^ SyntaxError: invalid syntax (hello_world.py, line 2)
I tried to follow this guide by adding removing from yaml https://hacs-pyscript.readthedocs.io/en/stable/reference.html#importing
my yaml config
pyscript: allow_all_imports: true hass_is_global: true
the doc above says this yaml will be ignored if GUI was used to install so I'm not sure what my settings need to be
my hello world.py file:
@service import requests << won't load thus don't show up under dev tools and errors in log as provided
def hello_world():
thanks anyone in advance for any help to get this working
lastly when I listed all in requirment doc logs stated requests was already installed and ignoring 2024-08-08 16:49:06.244 DEBUG (MainThread) [custom_components.pyscript] Skipping unpinned version of package 'requests' because version '2.32.3' is already installed