Datetime in the python script

It looks like it’s not possible to use datetime in pyhton scripts. I’m trying to run python_script from develeper tools but I’m getting KeyError: '__import__'

Are there any workaround for that? Or is something what I’m overlooking?

day = datetime.datetime.now().strftime("%A")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
    exec(compiled.code, restricted_globals)
  File "hot_watter.py", line 1, in <module>
KeyError: '__import__'

maybe, you can share more of your code?
That could help with debugging it… :wink:

That’s the whole code :smiley: I need to know the current day for the next steps.

the whole “hot_watter.py” just contains the assignment of the “day” variable?
Nothing else? o.O

Nothing else. What’s the problem? :slight_smile:

I wanted to try write small script, but the first line is problem

  File "hot_watter.py", line 1, in <module>

and I didn’t proceed in next steps. I tried some variants with that but without success. I have idea put the date as data if I call the service but that’s s*.