When following the example to import local modules the error "ModuleNotFoundError: No module named 'data'" happens
See original GitHub issueChecklist
- I added a descriptive title
- I searched for other issues and couldn’t find a solution or duplication
- I already searched in Google and didn’t find any good information or help
What happened?
Hi, I’m new on PyScript, so I was following the tutorial to declare local modules to train it. I put the html and data.py files in the same folder and opened the html file in a browser, but data module wasn’t found. I tried to change the “script defer src=” to all available tags, but the error persisted.
What browsers are you seeing the problem on? (if applicable)
Chrome, Other
Console info
# Here are the complete log from browser console
logger.ts:39 [py-config] config set from inline
logger.ts:39 [py-config] config set: {name: undefined, description: undefined, version: undefined, type: 'app', author_name: undefined, …}
logger.ts:39 [py-config] Initializing runtimes
logger.ts:39 [pyscript/pyodide] Runtime config: {name: 'pyodide-0.21.2', lang: 'python', src: 'https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js'}
logger.ts:39 [pyscript/main] checking for py-config
logger.ts:39 [pyscript/main] add py-loader
logger.ts:39 [py-loader] Loading runtime...
logger.ts:39 [pyscript/pyodide] Loading pyodide
DevTools failed to load source map: Could not load content for https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
pyodide.asm.js:10 Python initialization complete
logger.ts:39 [pyscript/pyodide] pyodide.loadPackage: micropip
logger.ts:39 [pyscript/pyodide] Loading micropip, pyparsing, packaging, distutils
logger.ts:39 [pyscript/pyodide] Loaded micropip, packaging, pyparsing, distutils
logger.ts:39 [pyscript/pyodide] importing pyscript.py
pyodide.asm.js:10 [Violation] 'setTimeout' handler took 848ms
logger.ts:39 [pyscript/pyodide] pyodide loaded and initialized
logger.ts:39 [py-loader] Runtime created...
logger.ts:39 [py-loader] Initializing components...
logger.ts:39 [py-script] py-mount: found 0 elements
logger.ts:39 [py-config] Loading env: (2) ['numpy', 'matplotlib']
logger.ts:39 [pyscript/pyodide] micropip install numpy,matplotlib
pyodide.asm.js:10 distutils already loaded from default channel
pyodide.asm.js:10 packaging already loaded from default channel
pyodide.asm.js:10 pyparsing already loaded from default channel
pyodide.asm.js:10 Loading numpy, matplotlib, cycler, six, fonttools, kiwisolver, pillow, python-dateutil, pytz
pyodide.asm.js:10 Loaded cycler, six, fonttools, python-dateutil, pytz, kiwisolver, pillow, matplotlib, numpy
logger.ts:39 [py-config] Paths to load: []
logger.ts:39 [py-config] All paths loaded
logger.ts:39 [py-loader] Initializing scripts...
logger.ts:39 [py-loader] Running post initializers...
logger.ts:39 [py-loader] Closing
logger.ts:39 [py-script] Initializing py-* event handlers...
logger.ts:39 [pyscript/runtime] PyScript page fully initialized
pyodide.asm.js:10 [Violation] 'setTimeout' handler took 4105ms
logger.ts:39 [pyscript/base] 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 506, in eval_code_async
await CodeRunner(
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 357, in run_async
coroutine = eval(self.code, globals, locals)
File "<exec>", line 2, in <module>
ModuleNotFoundError: No module named 'data'
fn @ logger.ts:39
evaluate @ base.ts:136
await in evaluate (async)
initialize @ runtime.ts:77
await in initialize (async)
(anonymous) @ pyconfig.ts:107
load (async)
loadRuntimes @ pyconfig.ts:106
connectedCallback @ pyconfig.ts:70
(anonymous) @ main.ts:12
(anonymous) @ main.ts:26
Additional Context
I did the same test using the Liver Server in VSCode, but the error were the same.
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Python error "ImportError: No module named"
The file needs to be called exactly __init__.py . If the extension is different such as in my case .py.bin then Python cannot...
Read more >How to Fix ModuleNotFoundError and ImportError
For example, consider the following project structure: └── myproject ... import aModuleNotFoundError: No module named 'a'.
Read more >ModuleNotFoundError: no module named Python Error ...
When you try to import a module in a Python file, Python tries to resolve this module in several ways. · As the...
Read more >How To Solve ModuleNotFoundError: No module named in ...
The first reason for ModuleNotFoundError: No module named is the module name is incorrect. For example, let's try to import the os module ......
Read more >How To Fix ModuleNotFoundError (No Module Named) in ...
ModuleNotFoundError no module named error is simply because the module you are trying to include is not installed. ; import keyword followed by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, we can close this. Thanks @douglasdcm. The issues that you face are basically because the documentation represents the current state of the repository while those
newer
features / paradigms aren’t available in the last release that is present at the/latest
URL.Thank you @FabioRosado ! Now it is working fine. The Scatter plot has been shown correctly 😃 Can I close this issue?