I'm trying to write an html file that can contact chat gpt.
This is the beginning of the code:
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" /> <script defer src="https://pyscript.net/latest/pyscript.js"></script> <py-script> import openai </py-script>
But when I run it it says:
ModuleNotFoundError: No module named 'openai'
Any idea how to install it on an html file?
I'm trying to figure out how to use:
pip install openai
,
But I don't know how to run bash commands from python.
I also tried using
It might be blocked by my proxy, I'm a beginner in Python, so please explain it briefly.
According to the Getting Started Document, use the
tag to import external modules:But, even so, this code:
gives the following error message:
The Pyodide link above is as follows:
openai
requiresrequests
, so until sockets are implemented in Pyodide (which PyScript uses) you won't be able to useopenai
module or many other modules in PyScript.However, it is possible to make asynchronous HTTP requests using PyScript/Pyodide: see the