travisdoesmath / sippycup

MIT License
13 stars 3 forks source link

ModuleNotFoundError: No module named 'micropip' #6

Closed rhildred closed 1 month ago

rhildred commented 1 month ago

Neat idea sippycup. It looks like a lot of it works from the below console. I did a fresh run from the frontend folder.

npm install
npm start

It draws the UI and then crashes on the micropip module not being found.

(index):50 Uncaught TypeError: Cannot read properties of null (reading 'style')
    at (index):50:26
react refresh:6 Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools
about:srcdoc:1 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
2
pyodide.asm.js:10 Loading distutils
pyodide.asm.js:10 Loaded distutils
pyodide.asm.js:10 distutils already loaded from default channel
pyodide.asm.js:10 Loading micropip, pyparsing, packaging
pyodide.asm.js:10 Loaded distutils
pyodide.asm.js:10 distutils already loaded from default channel
pyodide.asm.js:10 Loading micropip, pyparsing, packaging
2
pyodide.asm.js:10 Loaded pyparsing, packaging, micropip
pyodide.asm.js:10 Uncaught (in promise) PythonError: Traceback (most recent call last):
  File "/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'micropip'

    at new_error (pyodide.asm.js:10:218123)
    at pyodide.asm.wasm:0xdef7c
    at pyodide.asm.wasm:0xdf077
    at Module._pythonexc2js (pyodide.asm.js:10:900301)
    at Module.callPyObjectKwargs (pyodide.asm.js:10:119233)
    at Module.callPyObject (pyodide.asm.js:10:119442)
    at Function.apply (pyodide.asm.js:10:126886)
    at Object.apply (pyodide.asm.js:10:125914)
    at Object.pyimport (pyodide.asm.js:10:151534)
    at sippycup.js:102:1
    at async Module.start (sippycup.js:102:1)
pyodide.asm.js:10 Loading jinja2, markupsafe
pyodide.asm.js:10 [Violation] 'setTimeout' handler took 88ms
pyodide.asm.js:10 Loaded markupsafe, jinja2



rhildred commented 1 month ago

I worked around it by setting a 1ms timeout.

    await pyodide.loadPackage('micropip');
    setTimeout(async ()=>{
        const micropip = await pyodide.pyimport("micropip");
        await micropip.install('flask');    
    },1);

I couldn't see how your code had anything to do with it