-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No module named 'utils' on simple_clock.html #641
Comments
The issue is that the Pyscript code (via py-env) is looking for a file called 'utils.py' and can't find one, though you've probably guessed that. Here's why: By their very nature, browsers do not want websites to access things on your hard disk. You wouldn't want Twitter to be able to see your spreadsheets, right? If you're opening the example by, say, using File > Open in Chrome, or clicking on simple_clock.html in your file system, you are giving Chrome explicit permission to access that file, and only that file. Any other files on your hard drive, even if they're "right next to" the one you opened, are off limits. The way around this is to grant explicit permission to your browser to access other files on your HD, like 'utils.py' that you need in this case. The way to that is to use a simple server program to make them available 'on the network' (even if just locally to your computer). The link in that above error message has a simple method - many IDE's, like VS Code or PyCharm, also have the ability to serve your files so the browser can access them. |
Wow!! Great answer for stupid question. Very thank you for your kindness. I perfectly understand it. Thank you so mucj |
No stupid questions! |
Checklist
What is the issue/comment/problem?
I fully download this repo and run simple_clock.html file in examples folder by Chrome.
but it returns red errors, main massage is
No module named 'utils'
Anybody helpes me?
PyScript: Access to local files (using "Paths:" in ) is not available when directly opening a HTML file; you must use a webserver to serve the additional files. See this reference on starting a simple webserver with Python.
start time:
JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code .run(globals, locals) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run coroutine = eval(self.code, globals, locals) File "", line 3, in ModuleNotFoundError: No module named 'utils' )
JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async await CodeRunner( File "/lib/python3.10/site-packages/_pyodide/_base.py", line 351, in run_async coroutine = eval(self.code, globals, locals) File "", line 1, in ModuleNotFoundError: No module named 'utils' )
The text was updated successfully, but these errors were encountered: