What kind of HA are you running? On hass.io, the command line is very restricted. If you’re on hassbian in a venv you first have to activate it and run the command as ha user. Here are a few tips about it.