Pyscript not working on firefox extensions

I use pyscript but python scripts are not running in extensions popup. I tested my script by simply running the html file on firefox but when I specify the same html file on the manifest json file for firefox extension, I have only basic html elements in the extension popup and the script I wrote between the elements does not run, it just appears as text.
Could you help me please

Have you checked for errors?

It’s possible that pyscript tries to do something that’s not allowed in an extension context.

The error comes from content_security_policy, it tells me the host is invalid

That would do it. You have to include all scripts in your extension. So you have to download the js file and use it from a location within your extension. See also

It did not work. I have a network error when attempring to fetch ressources.

What kind of resources are you trying to load from where?

You told me to download the js file to use it as a local file but now when I load the web page it tells me “PyScript encountered an error while loading from file : NetworkError when attempting to fetch ressources”. I even have this error out of the extension, when I load the page in firefox.

It seems like your python is trying to read a file or load something, which is triggering this error. Alternatively if it’s the pyscript library, that would be bad, too.

You can easily find out what’s failing to load from the network tab in the developer tools.

EDIT: from a quick browse around the pyscript website it doesn’t seem well contained as a library, but more of an example project… So it might be doing random things that you wouldn’t expect from a library you want to load in an extension. The documentation also doesn’t seem very well suited toward library use.

Yes I also posted my issue on their forums but they do not really know to fix it either…
I’m going to wait a bit for the tool to develop, me who makes a point of using python on the web :sweat_smile:

There are a few potential issues that could be causing your Python script to not run in the extension popup. First, make sure that you have included all the necessary HTML elements in the popup. Without these, the script may not have anything to reference and thus will not run. Additionally, check to see if your script is properly linked to the HTML file. If it is not, the script will not be able to run. Finally, ensure that your Python interpreter is set up correctly and that all necessary libraries are installed. Without these, the Python script will not be able to execute. If you continue to have trouble getting your Python script to run in the extension popup, reach out to the PyScript community for help.

I fixed the problem. I modified the content-script-policy in manifest.json. I followed errors of the Firefox extensions debugger to allow every link in content-security-policy.