Python3 : No module named voluptuous

Trying to debug a python script which connects to an API then reports back results to Home Assistant. How can I run this script “as” home assistant and get the result directly back in the shell?

I’ve tried installing python on another linux box but I fear the errors I’ll get there are all about the class not being recognised (as it’s home assistant specific).

many thanks

EDIT: Progress, I installed the web terminal add-on and have tried running the python script but I get " no module named voluptuous" which is odd, because I thought HA used voluptuous itself?

Let’s take a step back. What script are you trying to run, and what platform are you using to run it.

It’s an integration with the Sling scheduling platform. I’m trying to develop it now with a private developer to replace a previous python script which integrated with humanity.
We’ve moved from Humanity to Sling so the API python integration script needed refactoring/rewriting

So you’re using python script integration or are you trying to write an integration?

A custom component. It’s a wee file called sensor.py within a folder in custom components. All this has previously worked swimmingly it’s just to change over from Humanity to Sling.

Just trying to debug why it says “error getting token” (the token relates to Sling)

If you want to truly debug it, you’d want to setup a dev environment, otherwise you’d want to ask these things in the dev section.

I’d love to setup a dev environment. Problem is I’m not sure how I’d be any better off? Doesn’t that just loop us back to the problem I originally posted that when trying to debug I just get “no module named voluptuous” ?

I’ve moved this to dev.

hmmm. So I managed to call the python script from services, but I think because the script is a custom component, I’m just getting loads and loads of

Error loading script sensor.py: Line 21: "_LOGGER" is an invalid variable name because it starts with "_", Line 21: "__name__" is an invalid variable name because it starts with "_", Line 45: "_LOGGER" is an invalid variable name because it starts with "_", Line 59: "_name" is an invalid attribute name because it starts with "_"., Line 60: "_type" is an invalid attribute name because it starts with "_"., Line 62: "_state" is an invalid attribute name because it starts with "_"., Line 63: "_unit_of_measurement" is an invalid attribute name because it starts with "_"., Line 68: "_name" is an invalid attribute name because it starts with "_"., Line 68: "_type" is an invalid attribute name because it starts with "_"., Line 73: "_state" is an invalid attribute name because it starts with "_"., Line 93: "_LOGGER" is an invalid variable name because it starts with "_", Line 97: "_type" is an invalid attribute name because it starts with "_"., Line 98: "_state" is an invalid attribute name because it starts with "_"., Line 99: "_type" is an invalid attribute name because it starts with "_"., Line 100: "_state" is an invalid attribute name because it starts with "_"., Line 102: "_state" is an invalid attribute name because it starts with "_"., Line 103: "_LOGGER" is an invalid variable name because it starts with "_", Line 156: "_LOGGER" is an invalid variable name because it starts with "_", Line 194: "_LOGGER" is an invalid variable name because it starts with "_"


Error loading script sensor.py: Line 59: "_name" is an invalid attribute name because it starts with "_"., Line 60: "_type" is an invalid attribute name because it starts with "_"., Line 62: "_state" is an invalid attribute name because it starts with "_"., Line 63: "_unit_of_measurement" is an invalid attribute name because it starts with "_"., Line 68: "_name" is an invalid attribute name because it starts with "_"., Line 68: "_type" is an invalid attribute name because it starts with "_"., Line 73: "_state" is an invalid attribute name because it starts with "_"., Line 97: "_type" is an invalid attribute name because it starts with "_"., Line 98: "_state" is an invalid attribute name because it starts with "_"., Line 99: "_type" is an invalid attribute name because it starts with "_"., Line 100: "_state" is an invalid attribute name because it starts with "_"., Line 102: "_state" is an invalid attribute name because it starts with "_".

a dev environment would let you debug line by line. I have no idea how you’re loading this as an integration. To me, it doesn’t seem like you’re doing it correctly. Can you please post where you’re putting the file and how you’re “calling the service”? It seems you’re mixing up python script with a normal integration.

yeah, I am probably mixing them up, I’m just clutching at straws to get some useful feedback with what’s going wrong with the script

So as I said, normally the file lives in the custom components directory contained in its own directory…

however as the logging I’m getting from the custom component isn’t helping me debug my issue, I’ve also popped a copy of the file into python scripts and am “calling the service” as you say from developer tools.

Currently trying to install a developer environment but because my windows box is on Win 7 this is fraught with all kinds of catches and snags.

That won’t work. It’s not the same environment and in general that’s not how code works. Python scripts (the integration) are small scripts that flow top to bottom. What’s in a integration is completely different. It’s managed by core and added into core in a different way.

The dev environment is the way to go, however if you don’t know python or how to use an IDE, this will be fruitless.

Thanks, yeah, I was figuring this out and coming to the same conclusion but thanks good to have it confirmed. I figured that’s why I was getting all the errors I mentioned

I don’t think so. Likely to be fruitless, but not definitely fruitless. I’ve used an IDE before and I’m not at all familiar with Python, but I can Google and I can do my best to interpret the logs. Wrangling with Kitematic and Virtualbox at the moment. If I was on Windows 10 I’d be running that dev environment by now…!

Thanks for your help.