import error: module not found
Issue type
Bug
How did you install PythonMonkey?
Installed from pip
OS platform and distribution
WSL - Ubuntu 23.04
Python version (python --version)
3.8.15
PythonMonkey version (pip show pythonmonkey)
0.2.2
Bug Description
I typed
from pythonmonkey import eval as js_eval,
it returns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bruce/.pyenv/versions/miniforge3-4.10.1-5/lib/python3.8/site-packages/pythonmonkey/__init__.py", line 16, in <module>
require("url")
File "/home/bruce/.pyenv/versions/miniforge3-4.10.1-5/lib/python3.8/site-packages/pythonmonkey/require.py", line 353, in require
return createRequire(filename)(moduleIdentifier)
pythonmonkey.SpiderMonkeyError: Error in file /home/bruce/.pyenv/versions/miniforge3-4.10.1-5/lib/python3.8/site-packages/pythonmonkey/node_modules/ctx-module/ctx-module.js, on line 236:
Error: module not found -- require('core-js/actual/dom-exception') from /home/bruce/.pyenv/versions/miniforge3-4.10.1-5/lib/python3.8/site-packages/pythonmonkey/builtin_modules/dom-exception.js
Stack Trace:
ctxRequire@/home/bruce/.pyenv/versions/miniforge3-4.10.1-5/lib/python3.8/site-packages/pythonmonkey/node_modules/ctx-module/ctx-module.js:120:7
Standalone code to reproduce the issue
No response
Relevant log output or backtrace
No response
Additional info if applicable
Conda version: 23.9.0
nodejs version: 6.13.1
What branch of PythonMonkey were you developing on? (If applicable)
No response
Same problem as you... Have you find any solutions?
have the same issue
i found a temporary solution, which requires you to install node and npm.
goto <python install dir>/Lib/site-packages/pythonmonkey/node_modules and run npm install core-js
Can this error be resolved in the next version. I also have this error when using.
@Smawexi @lelemka0 @francescocassini can you provide a full reproducer? How is core-js configured into this?
@philippedistributive I made some attempts and found that the problem always occurs after upgrading.
The loss of core-js occurred when upgrading from 0.2.1 to 0.2.2, because pminit was not upgraded at the same time.
core-js is a new dependency in 0.2.2, so it is missing. If the js dependency does not change when the module is upgraded, there will be no exception.
I think the problem comes from here, it doesn't make a requirement on the version of pminit.
https://github.com/Distributive-Network/PythonMonkey/blob/9f52f581e1f1d7e741a6049d95e397efd893d44f/pyproject.toml#L33
As a temporary workaround, use pip install pythonmonkey --force-reinstall instead of pip install pythonmonkey --upgrade when upgrading modules.
I am also encountering with the same issue with latest version 0.4.0 :(
I am also encountering with the same issue with latest version 0.4.0 :(
Try pip install pythonmonkey --force-reinstall
I am also encountering with the same issue with latest version 0.4.0 :(
Try
pip install pythonmonkey --force-reinstall
Tried, but it still didn't work
@Smawexi @lelemka0 @francescocassini @longavailable @ChrisDoufu are you still having this issue after installing the latest release (v0.6.0) by doing the following:
pip install --upgrade --force-reinstall pythonmonkey