Beginner: Unable to find component python_script

Hi,

i´ve done this:
Add to configuration.yaml: python_script:
Create folder /python_scripts
Create a file hello_world.py in the folder and give it this content…

And get this :frowning:

ERROR (MainThread) [homeassistant.loader] Unable to find component python_script
17-06-27 22:59:38 ERROR (MainThread) [homeassistant.setup] Setup failed for python_script: Component not found.

What´s wrong?

Mike

What version of HA are you running? You need version 0.47.0 or later as that is the version this component was added in.

Second option is, does your HA user have read rights to the folder /python_scripts?

https://wiki.archlinux.org/index.php/File_permissions_and_attributes

Damn… running 0.41.0 - thank you =)

https://home-assistant.io/docs/hassbian/upgrading/

should get you updated.

already running - thanks

I am having the same problem. Here is my config:

# Set up python scripts entered by jp
python_script: 

and my directory structure…not sure about ownership, I log in as “pi”, I have changed the python_scripts ownership to pi and homeassistant, no difference

-rwxrwxr-- 1 pi pi 125 Jun  1 09:16 hello_world.py
pi@hassbian:/home/homeassistant/conf/python_scripts $ ls -l /home/homeassistant/conf
total 184
-rw-r--r-- 1 pi            pi            105667 Jun  1 09:49 access.log
-rw-r--r-- 1 pi            root           47682 Jun  1 10:32 appdaemon.log
-rwxr-xr-x 1 pi            pi               930 May 27 21:40 appdaemon.yaml
-rw-r--r-- 1 root          root             380 May  8 13:55 appdaemon.yaml.save
drwxr-xr-x 2 pi            pi              4096 Jun  1 09:29 apps
drwxr-xr-x 5 pi            pi              4096 May  8 16:25 compiled
drwxr-xr-x 2 root          root            4096 May 29 12:29 dashboards
-rw-r--r-- 1 pi            pi                 0 May 24 17:18 error.log
drwxr-xr-x 2 homeassistant homeassistant   4096 Jun  1 09:16 python_scripts

HA Version
image
Error message

2018-06-01 10:32:00 WARNING (Thread-15) [homeassistant.components.python_script] Folder python_scripts not found in configuration folder
2018-06-01 10:32:00 ERROR (MainThread) [homeassistant.setup] Setup failed for python_script: Component failed to initialize.

What am I missing, please?

What is your HA configuration folder? Should be shown directly under that version information.

image

As you can see, in my case it’s /home/homeassistant/.homeassistant. If it’s the same for you, then you need to put it at /home/homeassistant/.homeassistant/python_scripts. E.g.:

pi@raspberrypi:~ $ ls -ld /home/homeassistant/.homeassistant/python_scripts/
drwxr-xr-x 2 homeassistant homeassistant 4096 May 17 13:59 /home/homeassistant/.homeassistant/python_scripts/

That did it for me…what is confusing is the instructions that say “Create folder /python_scripts” and I put it under the “conf” folder in the “homeassistant” directory. pi@hassbian:/home/homeassistant/conf/python_scripts
Thanks much!!

1 Like

I think you tried to say it says "Create folder <config>/python_scripts". But, yes, when I first started, I saw <config> mentioned in several places without defining what that meant. I eventually did find it stated more explicitly somewhere, but it took a while and that was a bit frustrating.

FWIW, my installation doesn’t have a conf folder:

pi@raspberrypi:~ $ ls -la /home/homeassistant/
total 52
drwxr-xr-x  5 homeassistant homeassistant 4096 Apr  9 08:44 .
drwxr-xr-x  4 root          root          4096 Mar 15 21:15 ..
-rw-------  1 homeassistant homeassistant 6342 May 21 12:37 .bash_history
-rw-r--r--  1 homeassistant homeassistant  220 May 15  2017 .bash_logout
-rw-r--r--  1 homeassistant homeassistant 3523 Mar 13 16:55 .bashrc
drwx------  3 homeassistant homeassistant 4096 Mar 15 21:22 .cache
drwxr-xr-x 11 homeassistant homeassistant 4096 Jun  1 13:27 .homeassistant
drwxr-xr-x  2 homeassistant homeassistant 4096 Mar 15 22:25 .nano
-rw-r--r--  1 homeassistant homeassistant  675 May 15  2017 .profile
-rw-------  1 homeassistant homeassistant  332 Mar 29 16:01 .python_history
-rw-------  1 homeassistant homeassistant 1024 Mar 18 22:22 .rnd
-rw-r--r--  1 homeassistant homeassistant   66 Mar 18 22:52 .selected_editor

But then I don’t use Hass.io, appdaemon or hadashboard.

Interesting, I have been putting a lot of stuff under the conf folder

pi@hassbian:/home/homeassistant/conf $ dir
access.log  appdaemon.log  appdaemon.yaml  appdaemon.yaml.save  apps  compiled  dashboards  error.log
pi@hassbian:/home/homeassistant/conf $

and maybe should have been putting it here :rofl:

pi@hassbian:/home/homeassistant $ cd .homeassistant
pi@hassbian:/home/homeassistant/.homeassistant $ dir
appdaemon\ problem.txt  contextMenu.xml       home-assistant.log    old_automations.yaml  secrets.yaml          zwscene.xml
automations.yaml        customize.yaml        home-assistant_v2.db  options.xml           shortcuts.xml
backup                  deps                  known_devices.yaml    OZW_Log.txt           stylers.xml
Common\ Commands.txt    entity_registry.yaml  langs.xml             pyozw.sqlite          tts
configuration.yaml      fitbit.conf           mytemplate.txt        python_scripts        zwcfg_0xca522938.xml
config.xml              groups.yaml           my.yaml               scripts.yaml          zwcfg_0xd4283da0.xml

Very confusing :tired_face::zipper_mouth_face:

Thanks again for your help.

PS, the more I think about this, I believe there are two sets of “users”, one is the casual user that just wants to use the components available without customization. These users have access to the /home/homeassistant/ directory where they have the /conf/, /apps/, /compiled/ and /dashboard/ directories and they do not know about the ./homeassistant/ because it is “hidden” and available to more knowledgeable linux users and developers. Anyway, this is all a bit confusing and I am sure it causes a lot of grief for noobs like me.

I was confused by /python_scripts/ as well. Figured this part out thanks to your post.

However, I’m still unable to run the hello world sample :frowning:

  • dev-info shows:
    Home Assistant
    0.88.2

    Path to configuration.yaml: /config

  • I’ve added ‘python_script:’ to the bottom of my /config/configuration.yaml

  • Script in place in /config/python_scripts/hello_world.py

Whenever I try to call the python_script/hello_world service I get a “Failed to call service python_script/hello_world/null.” message

Any hints?

EDIT: Works when calling python_script.hello_world. Phuu, that was harder than it could be.