PythonMonkey icon indicating copy to clipboard operation
PythonMonkey copied to clipboard

import error: module not found

Open longavailable opened this issue 2 years ago • 9 comments

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

longavailable avatar Nov 22 '23 06:11 longavailable

Same problem as you... Have you find any solutions?

francescocassini avatar Nov 23 '23 05:11 francescocassini

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

lelemka0 avatar Nov 23 '23 12:11 lelemka0

Can this error be resolved in the next version. I also have this error when using.

Smawexi avatar Dec 09 '23 02:12 Smawexi

@Smawexi @lelemka0 @francescocassini can you provide a full reproducer? How is core-js configured into this?

philippedistributive avatar Apr 04 '24 17:04 philippedistributive

@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.

lelemka0 avatar Apr 04 '24 23:04 lelemka0

I am also encountering with the same issue with latest version 0.4.0 :(

ChrisDoufu avatar Apr 13 '24 10:04 ChrisDoufu

I am also encountering with the same issue with latest version 0.4.0 :(

Try pip install pythonmonkey --force-reinstall

lelemka0 avatar Apr 13 '24 17:04 lelemka0

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

ChrisDoufu avatar Apr 14 '24 11:04 ChrisDoufu

@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

zollqir avatar May 06 '24 15:05 zollqir