文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 <html> <script src="https://www.tomoyan.net/_media/javascript/jquery/terminal/jquery.terminal-2.7.1.min.js?cache=recache"></script> <link href="https://www.tomoyan.net/_media/javascript/jquery/terminal/jquery.terminal-2.7.1.css?cache=recache" rel="stylesheet"/> <!--<link href="/_media/python/pyodide/0.22.0a1/renderedhtml.css?cache=recache" rel="stylesheet"/>--> <style> #terminal { height: 400px; background-color: #000; color: #fff; font-family: monospace; font-size: 12px; padding: 10px; } </style> <script> self.startTime = new Date(); /*self.languagePluginUrl = '/_media/python/pyodide/0.22.0a1/';*/ </script> <script src="/_media/python/pyodide/0.22.0a1/pyodide.js?cache=-1"></script> <script> "use strict"; function sleep(s) { return new Promise((resolve) => setTimeout(resolve, s)); } async function main() { let term; globalThis.pyodide = await loadPyodide({ stdin: () => { let result = prompt(); echo(result); return result; }, }); let namespace = pyodide.globals.get("dict")(); pyodide.runPython( ` import sys import pyodide from pyodide.ffi import to_js from pyodide.console import PyodideConsole, repr_shorten, BANNER import __main__ BANNER = "Welcome to the Pyodide terminal emulator 🐍 Version " + pyodide.__version__ + "\\n" + BANNER pyconsole = PyodideConsole(__main__.__dict__) import builtins async def await_fut(fut): res = await fut if res is not None: builtins._ = res return to_js([res], depth=1) def clear_console(): pyconsole.buffer = [] `, { globals: namespace }, ); let repr_shorten = namespace.get("repr_shorten"); let banner = namespace.get("BANNER"); let await_fut = namespace.get("await_fut"); let pyconsole = namespace.get("pyconsole"); let clear_console = namespace.get("clear_console"); const echo = (msg, ...opts) => term.echo( msg .replaceAll("]]", "]]") .replaceAll("[[", "[["), ...opts, ); namespace.destroy(); let ps1 = ">>> ", ps2 = "... "; async function lock() { let resolve; let ready = term.ready; term.ready = new Promise((res) => (resolve = res)); await ready; return resolve; } async function interpreter(command) { let unlock = await lock(); term.pause(); // multiline should be split (useful when pasting) for (const c of command.split("\n")) { let fut = pyconsole.push(c); term.set_prompt(fut.syntax_check === "incomplete" ? ps2 : ps1); switch (fut.syntax_check) { case "syntax-error": term.error(fut.formatted_error.trimEnd()); continue; case "incomplete": continue; case "complete": break; default: throw new Error(`Unexpected type ${ty}`); } // In JavaScript, await automatically also awaits any results of // awaits, so if an async function returns a future, it will await // the inner future too. This is not what we want so we // temporarily put it into a list to protect it. let wrapped = await_fut(fut); // complete case, get result / error and print it. try { let [value] = await wrapped; if (value !== undefined) { echo( repr_shorten.callKwargs(value, { separator: "\n<long output truncated>\n", }), ); } if (pyodide.isPyProxy(value)) { value.destroy(); } } catch (e) { if (e.constructor.name === "PythonError") { const message = fut.formatted_error || e.message; term.error(message.trimEnd()); } else { throw e; } } finally { fut.destroy(); wrapped.destroy(); } } term.resume(); await sleep(10); unlock(); } term = jQuery("#terminal"); term.text(''); //term.clear() self.endTime = new Date(); var ms = self.endTime.getTime() - self.startTime.getTime(); banner = "Interpreter Loading time: " + ms + "ms\n" + banner; term.terminal(interpreter, { greetings: banner, prompt: ps1, completionEscape: false, completion: function (command, callback) { callback(pyconsole.complete(command).toJs()[0]); }, keymap: { "CTRL+C": async function (event, original) { clear_console(); term.enter(); echo("KeyboardInterrupt"); term.set_command(""); term.set_prompt(ps1); }, TAB: (event, original) => { const command = term.before_cursor(); // Disable completion for whitespaces. if (command.trim() === "") { term.insert("\t"); return false; } return original(event); }, }, }); window.term = term; pyconsole.stdout_callback = (s) => echo(s, { newline: false }); pyconsole.stderr_callback = (s) => { term.error(s.trimEnd()); }; term.ready = Promise.resolve(); pyodide._api.on_fatal = async (e) => { term.error( "Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.", ); term.error("The cause of the fatal error was:"); term.error(e); term.error("Look in the browser console for more details."); await term.ready; term.pause(); await sleep(15); term.pause(); }; const searchParams = new URLSearchParams(window.location.search); if (searchParams.has("noblink")) { $(".cmd-cursor").addClass("noblink"); } } window.console_ready = main(); /*jQuery(function() { languagePluginLoader.then(() => { function pushCode(line) { handleResult(c.push(line)) } self.endTime = new Date(); var ms = self.endTime.getTime() - self.startTime.getTime(); var term = jQuery('#terminal'); term.text(''); term.terminal( pushCode, { greetings: "Interpreter Loading time: " + ms + "ms\r\n" + "Welcome to the Pyodide terminal emulator 🐍" + " Version " + pyodide.version(), prompt: "[[;red;]>>> ]" } ); window.term = term; pyodide.runPython(` import io, code, sys from js import term, pyodide class Console(code.InteractiveConsole): def runcode(self, code): sys.stdout = io.StringIO() sys.stderr = io.StringIO() term.runPython("\\n".join(self.buffer)) _c = Console(locals=globals()) `) var c = pyodide.pyimport('_c') function handleResult(result) { if (result) { term.set_prompt('[[;gray;]... ]') } else { term.set_prompt('[[;red;]>>> ]') var stderr = pyodide.runPython("sys.stderr.getvalue()").trim() if (stderr) { term.echo(`[[;red;]${stderr}]`) } else { var stdout = pyodide.runPython("sys.stdout.getvalue()") if (stdout) { term.echo(stdout.trim()) } } } } term.runPython = function(code) { pyodide.runPythonAsync(code).then( term.handlePythonResult, term.handlePythonError ) } term.handlePythonResult = function(result) { if (result === undefined) { return } else if (result['_repr_html_'] !== undefined) { term.echo(result['_repr_html_'], {raw: true}) } else { term.echo(result.toString()) } } term.handlePythonError = function(result) { term.error(result.toString()) } }); });*/ </script> </html> ====== Pyodide - Web ブラウザで動作する Python 環境 ====== ソースコード: [[https://github.com/iodide-project/pyodide|GitHub - iodide-project/pyodide: The Python scientific stack, compiled to WebAssembly]]\\ \\ **Pyodide** (パイオダイド) とは [[https://mozilla.org/|Mozilla]] が開発中の Web ブラウザーの WebAssembly で動作する Python の実装である。\\ Web ブラウザ上で Python 言語および Python のデータサイエンスライブラリ (NumPy, Scipy, Pandas, Matplotlib... など[[https://github.com/iodide-project/pyodide/tree/master/packages|pyodide/packages]] を参照) をそのまま使ってプログラミングできるような環境を目指している。\\ **Pyodide** は [[https://ja.wikipedia.org/wiki/Emscripten|Emscripten]] (C/C++ から WebAssembly を生成するコンパイラ) を利用した [[https://github.com/dgym/cpython-emscripten|cpython-emscripten]] を元に開発されている。\\ ===== 関連プロジェクト ===== [[https://pyscript.net/|PyScript is an open source platform for Python in the browser.]]\\ [[https://github.com/sparckles/starfyre|sparckles/starfyre: A reactive, WASM based SSR Python Web Framework for Front-End Applications]]\\ ===== コンソール ====== <WRAP prewrap 100% #terminal> <html>Python Interpreter Loading...</html> </WRAP> \\ <code python> >>> import sys >>> sys.version '3.10.2 (main, Sep 25 2022, 05:41:13) [Clang 16.0.0 (https://github.com/llvm/llvm-project a4a29438f451370ed241dde30bfc' >>> sys.version_info sys.version_info(major=3, minor=10, micro=2, releaselevel='final', serial=0) >>> import platform >>> platform.system() 'Emscripten' >>> platform.platform() 'Emscripten-3.1.21-wasm32-32bit' >>> </code> ===== インストール ===== [[https://github.com/iodide-project/pyodide/releases|Releases · iodide-project/pyodide · GitHub]] より [[https://github.com/pyodide/pyodide/releases/download/0.22.0a1/pyodide-0.22.0a1.tar.bz2|pyodide-0.22.0a1.tar.bz2]] をダウンロードして Web サーバーに配置する。\\ <WRAP color_term> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>curl</b> <b class=HIK>-LO</b> https://github.com/pyodide/pyodide/releases/download/0.22.0a1/pyodide-0.22.0a1.tar.bz2 </pre></html></WRAP> <WRAP color_result><html><pre> % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 182M 100 182M 0 0 3010k 0 0:01:02 0:01:02 --:--:-- 2627k </pre></html></WRAP> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>mkdir</b> <b class=HIK>-p</b> ~/dokuwiki/data/media/python/pyodide/ <b class=GRN>$</b> <b class=HIY>tar</b> jxvf pyodide-0.22.0a1.tar.bz2 <b class=HIK>-C</b> ~/dokuwiki/data/media/python/pyodide/ </pre></html></WRAP> <WRAP color_result_long><html><pre> pyodide/ pyodide/fpcast_test-0.1.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/atomicwrites-1.4.0-py2.py3-none-any.whl pyodide/Jinja2-3.1.2-py3-none-any.whl pyodide/pytest-7.1.2-py3-none-any.whl pyodide/six-1.16.0-py2.py3-none-any.whl pyodide/pyodide_tblib-1.7.1-py3-none-any.whl pyodide/MarkupSafe-2.1.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pluggy-1.0.0-py2.py3-none-any.whl pyodide/pytz-2022.1-py2.py3-none-any.whl pyodide/pyparsing-3.0.9-py3-none-any.whl pyodide/attrs-21.4.0-py2.py3-none-any.whl pyodide/micropip-0.1.0-py3-none-any.whl pyodide/iniconfig-1.1.1-py2.py3-none-any.whl pyodide/sharedlib_test_py-1.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/repodata.json pyodide/pyodide_py.tar pyodide/test.html pyodide/module_test.html pyodide/webworker.js pyodide/webworker_dev.js pyodide/module_webworker_dev.js pyodide/CLAPACK-3.2.1.zip pyodide/suitesparse-5.11.0.zip pyodide/libmagic-5.42.zip pyodide/numpy-1.22.4-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pkgconfig-1.5.5-py3-none-any.whl pyodide/kiwisolver-1.4.3-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/python_dateutil-2.8.2-py2.py3-none-any.whl pyodide/html5lib-1.1-py2.py3-none-any.whl pyodide/future-0.18.2-py3-none-any.whl pyodide/future-tests.tar pyodide/joblib-tests.tar pyodide/swiglpk-5.0.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/cffi_example-0.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/python_solvespace-3.0.7-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/sqlalchemy-tests.tar pyodide/cytoolz-tests.tar pyodide/decorator-5.1.1-py3-none-any.whl pyodide/jedi-tests.tar pyodide/pyodide.mjs.map pyodide/pyodide.mjs pyodide/tsconfig.tsbuildinfo pyodide/pyodide.js.map pyodide/pyodide.js pyodide/pyodide.asm.data pyodide/pyodide.asm.wasm pyodide/pyodide.asm.js pyodide/pyodide.d.ts pyodide/package.json pyodide/console.html pyodide/openssl-1.1.1n.zip pyodide/ssl-1.0.0.zip pyodide/cpp-exceptions-test-0.1.zip pyodide/sharedlib-test-1.0.zip pyodide/sqlite3-1.0.0.zip pyodide/test-1.0.0.zip pyodide/distutils-1.0.0.zip pyodide/lzma-1.0.0.zip pyodide/setuptools-62.6.0-py3-none-any.whl pyodide/regex-2022.6.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/regex-tests.tar pyodide/py-1.11.0-py2.py3-none-any.whl pyodide/more_itertools-8.13.0-py3-none-any.whl pyodide/packaging-21.3-py3-none-any.whl pyodide/geos-3.10.3.zip pyodide/libhdf5-1.12.1.zip pyodide/numpy-tests.tar pyodide/lxml-4.9.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/nose-1.3.7-py3-none-any.whl pyodide/tqdm-4.64.0-py2.py3-none-any.whl pyodide/tomli_w-1.0.0-py3-none-any.whl pyodide/joblib-1.1.0-py2.py3-none-any.whl pyodide/docutils-0.18.1-py2.py3-none-any.whl pyodide/ruamel.yaml-0.17.21-py3-none-any.whl pyodide/SQLAlchemy-1.4.37-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/cytoolz-0.11.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pyproj-3.3.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/cycler-0.11.0-py3-none-any.whl pyodide/Brotli-1.0.9-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/uncertainties-3.1.7-py2.py3-none-any.whl pyodide/uncertainties-tests.tar pyodide/svgwrite-1.4.2-py3-none-any.whl pyodide/gmpy2-2.1.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/freesasa-2.1.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pytest_benchmark-3.4.1-py2.py3-none-any.whl pyodide/python_sat-0.1.7.dev19-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/jedi-0.18.1-py2.py3-none-any.whl pyodide/cffi-1.15.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/coverage-6.4.4-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/soupsieve-2.3.2.post1-py3-none-any.whl pyodide/cssselect-1.1.0-py2.py3-none-any.whl pyodide/pyrsistent-0.18.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/asciitree-0.3.3-py3-none-any.whl pyodide/xlrd-2.0.1-py2.py3-none-any.whl pyodide/sympy-1.10.1-py3-none-any.whl pyodide/Logbook-1.5.3-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/newick-1.3.2-py2.py3-none-any.whl pyodide/nltk-3.7-py3-none-any.whl pyodide/nltk-tests.tar pyodide/pydantic-1.9.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/wrapt-1.14.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/python_magic-0.4.27-py2.py3-none-any.whl pyodide/demes-0.2.2-py3-none-any.whl pyodide/cryptography-38.0.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/parso-0.8.3-py2.py3-none-any.whl pyodide/bcrypt-4.0.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/retrying-1.3.3-py3-none-any.whl pyodide/bleach-5.0.0-py3-none-any.whl pyodide/cloudpickle-2.1.0-py3-none-any.whl pyodide/jsonschema-4.6.0-py3-none-any.whl pyodide/jsonschema-tests.tar pyodide/pyclipper-1.3.0.post3-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pycparser-2.21-py2.py3-none-any.whl pyodide/beautifulsoup4-4.11.1-py3-none-any.whl pyodide/beautifulsoup4-tests.tar pyodide/PyYAML-6.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/toolz-0.11.2-py3-none-any.whl pyodide/toolz-tests.tar pyodide/matplotlib_pyodide-0.1.1-py3-none-any.whl pyodide/msgpack-1.0.4-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/certifi-2022.6.15-py3-none-any.whl pyodide/fonttools-4.33.3-py3-none-any.whl pyodide/Pygments-2.12.0-py3-none-any.whl pyodide/typing_extensions-4.2.0-py3-none-any.whl pyodide/threadpoolctl-3.1.0-py3-none-any.whl pyodide/lazy_object_proxy-1.7.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/webencodings-0.5.1-py2.py3-none-any.whl pyodide/mpmath-1.2.1-py3-none-any.whl pyodide/mpmath-tests.tar pyodide/distlib-0.3.4-py2.py3-none-any.whl pyodide/fonts/ pyodide/fonts/DejaVuSans-Bold.ttf pyodide/fonts/DejaVuSans-BoldOblique.ttf pyodide/fonts/DejaVuSans-Oblique.ttf pyodide/fonts/DejaVuSans.ttf pyodide/fonts/DejaVuSansDisplay.ttf pyodide/fonts/DejaVuSansMono-Bold.ttf pyodide/fonts/DejaVuSansMono-BoldOblique.ttf pyodide/fonts/DejaVuSansMono-Oblique.ttf pyodide/fonts/DejaVuSansMono.ttf pyodide/fonts/DejaVuSerif-Bold.ttf pyodide/fonts/DejaVuSerif-BoldItalic.ttf pyodide/fonts/DejaVuSerif-Italic.ttf pyodide/fonts/DejaVuSerif.ttf pyodide/fonts/DejaVuSerifDisplay.ttf pyodide/fonts/Humor-Sans.ttf pyodide/fonts/LICENSE_DEJAVU pyodide/fonts/LICENSE_STIX pyodide/fonts/STIXGeneral.ttf pyodide/fonts/STIXGeneralBol.ttf pyodide/fonts/STIXGeneralBolIta.ttf pyodide/fonts/STIXGeneralItalic.ttf pyodide/fonts/STIXNonUni.ttf pyodide/fonts/STIXNonUniBol.ttf pyodide/fonts/STIXNonUniBolIta.ttf pyodide/fonts/STIXNonUniIta.ttf pyodide/fonts/STIXSizFiveSymReg.ttf pyodide/fonts/STIXSizFourSymBol.ttf pyodide/fonts/STIXSizFourSymReg.ttf pyodide/fonts/STIXSizOneSymBol.ttf pyodide/fonts/STIXSizOneSymReg.ttf pyodide/fonts/STIXSizThreeSymBol.ttf pyodide/fonts/STIXSizThreeSymReg.ttf pyodide/fonts/STIXSizTwoSymBol.ttf pyodide/fonts/STIXSizTwoSymReg.ttf pyodide/fonts/cmb10.ttf pyodide/fonts/cmex10.ttf pyodide/fonts/cmmi10.ttf pyodide/fonts/cmr10.ttf pyodide/fonts/cmss10.ttf pyodide/fonts/cmsy10.ttf pyodide/fonts/cmtt10.ttf pyodide/galpy-1.8.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/numcodecs-tests.tar pyodide/biopython-1.79-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/rebound-3.19.8-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/cftime-1.6.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/scipy-tests.tar pyodide/unyt-2.8.0-py2.py3-none-any.whl pyodide/zarr-2.11.3-py3-none-any.whl pyodide/imageio-2.19.3-py3-none-any.whl pyodide/scikit-learn-tests.tar pyodide/statsmodels-tests.tar pyodide/PIL-9.1.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pycryptodome-3.15.0-cp35-abi3-emscripten_3_1_21_wasm32.whl pyodide/pycryptodome-tests.tar pyodide/traits-6.3.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/traits-tests.tar pyodide/termcolor-1.1.0-py3-none-any.whl pyodide/bitarray-2.5.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/bitarray-tests.tar pyodide/tomli-2.0.1-py3-none-any.whl pyodide/optlang-1.5.2-py2.py3-none-any.whl pyodide/optlang-tests.tar pyodide/sympy-tests.tar pyodide/numcodecs-0.9.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/yt-4.0.4-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/bokeh-2.4.3-py3-none-any.whl pyodide/networkx-2.8.4-py3-none-any.whl pyodide/networkx-tests.tar pyodide/scipy-1.9.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/colorspacious-1.1.2-py2.py3-none-any.whl pyodide/unyt-tests.tar pyodide/zarr-tests.tar pyodide/scikit_learn-1.1.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/scikit-image-tests.tar pyodide/scikit_image-0.19.3-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/statsmodels-0.13.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/xgboost-1.6.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/cmyt-1.0.4-py3-none-any.whl pyodide/cmyt-tests.tar pyodide/matplotlib-3.5.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/matplotlib-tests.tar pyodide/Shapely-1.8.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/shapely-tests.tar pyodide/pandas-1.5.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pandas-tests.tar pyodide/mne-1.0.3-py3-none-any.whl pyodide/mne-tests.tar pyodide/boost_histogram-1.3.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/RobotRaconteur-0.15.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/msprime-1.2.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/h5py-3.7.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/h5py-tests.tar pyodide/PyWavelets-1.3.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pywavelets-tests.tar pyodide/autograd-1.4-py3-none-any.whl pyodide/autograd-tests.tar pyodide/xarray-2022.3.0-py3-none-any.whl pyodide/xarray-tests.tar pyodide/astropy-5.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pyerfa-2.0.0.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/pyerfa-tests.tar pyodide/patsy-0.5.2-py2.py3-none-any.whl pyodide/patsy-tests.tar pyodide/tskit-0.4.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/nlopt-2.7.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/sparseqr-1.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/reboundx-3.7.1-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/gsw-3.4.0-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/gsw-tests.tar pyodide/b2d-0.7.2-cp310-cp310-emscripten_3_1_21_wasm32.whl pyodide/opencv_python-4.6.0.66-cp310-cp310-emscripten_3_1_21_wasm32.whl </pre></html></WRAP> <WRAP color_command><html><pre> <b class=GRN>$</b> <b class=HIY>mv</b> ~/dokuwiki/data/media/python/pyodide/pyodide/ ~/dokuwiki/data/media/python/pyodide/0.22.0a1 </pre></html></WRAP> </WRAP> ==== console.html を実行する ==== console.html を実行するには修正が必要である。\\ **pyodide_dev.js** をロードする前に **self.languagePluginUrl** の設定が必要である。(これを設定しないと内部のロード処理が全てのファイルが Web サーバーのルートに置かれていると仮定して動作する)\\ <file html console.html> <!doctype html> <html> <head> ... <script> self.languagePluginUrl = './'; </script> <script src="./pyodide_dev.js"></script> </head> ... </file> 更に Microsoft Edge で実行可能にするには、以下の修正が必要である。\\ 48~52 行目\\ <file javascript pyodide_dev.js> try { dirs = FS.readdir(rootpath); } catch (err) { return; } </file> **} catch {** を **} catch (err) {** に修正。\\ 87~92 行目\\ <file javascript pyodide_dev.js> try { self.importScripts(url); onload(); } catch (err) { onerror(); } </file> **} catch {** を **} catch (err) {** に修正。\\ ===== 参考文献 ===== [[https://hacks.mozilla.org/2019/04/pyodide-bringing-the-scientific-python-stack-to-the-browser/|Pyodide: Bringing the scientific Python stack to the browser - Mozilla Hacks - the Web developer blog]]\\ [[https://www.publickey1.jp/blog/22/rubywebassemblywasiwebassemblyruby.html|]]\\ python/pyodide.txt 最終更新: 2024/06/27 12:22by ともやん