extremeheat / JSPyBridge

🌉. Bridge to interoperate Node.js and Python
MIT License
684 stars 52 forks source link

ModuleNotFoundError: No module named '[x]'] #123

Open ikb42 opened 8 months ago

ikb42 commented 8 months ago

When the server has recently started and the Node app has recently started (specifically AWS Elastic Beanstalk new instance deployed)

When I call pd = await python('pandas'); I get an error like this: ModuleNotFoundError: No module named 'pandas'] This is despite there definitely being such a module, I am using the env variable PYTHON_BIN to set the path /usr/bin/python3.9

After some time, if I call this again it works. So I have setup a recursive function that on app start, calls await python over and over again (with a pause) until it succeeds, it seems to take about 5 mins to work. After that all works well.

extremeheat commented 8 months ago

Can you provide the stack trace for the error?

ikb42 commented 8 months ago

:  at async loadPython (/var/app/current/src/server/utils/library/python/python.js:16:18)
: ... across the bridge ...
": > return _bootstrap._gcd_import(name[level:], package, level)"
:  at import_module (/usr/lib64/python3.9/importlib/__init__.py:127)
:  at _gcd_import (<frozen importlib._bootstrap>:1030)
:  at _find_and_load (<frozen importlib._bootstrap>:1007)
:  at _find_and_load_unlocked (<frozen importlib._bootstrap>:984)
: *** JS *** ModuleNotFoundError: No module named 'pandas']```