Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Importing requests or aiohttp #508

Answered by craigbarratt
tobiasb asked this question in General
Discussion options

I'm writing a service that fetches a URL, code is as simple as it gets. I read https://hacs-pyscript.readthedocs.io/en/latest/reference.html#importing which said how to use requests properly but recommends aiohttp. I tried both but I get

Exception in </config/pyscript/.py> line 1: import aiohttp ^ ModuleNotFoundError: import of aiohttp not allowed

and

Exception in </config/pyscript/.py> line 1: import requests ^ ModuleNotFoundError: import of requests not allowed

This is my pyscript section of configuration.yaml

pyscript:
 allow_all_imports: true
 hass_is_global: true

Anyone got an idea what I'm doing wrong?

You must be logged in to vote

Note from the documentation:

Pyscript can be configured using the UI, or via yaml..... You can’t mix these two methods - your initial choice determines how you should update these settings later. If you want to switch configuration methods you will need to uninstall and reinstall pyscript.

Replies: 2 comments 1 reply

Comment options

Have you restarted HASS? Another thing to try is to change those two settings via HACS.

You must be logged in to vote
0 replies
Comment options

Note from the documentation:

Pyscript can be configured using the UI, or via yaml..... You can’t mix these two methods - your initial choice determines how you should update these settings later. If you want to switch configuration methods you will need to uninstall and reinstall pyscript.

You must be logged in to vote
1 reply
Comment options

This was it, I thought I had configuration through yaml set up but turns out it was UI instead. Cheers!

Answer selected by tobiasb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /