JSPyBridge
JSPyBridge copied to clipboard
How to install a python package so I can use it in node
Couldn't find the info anywhere, maybe I didn't look hard enough. I found how to install node packages in python but not vice-versa.
The python packages need to be installed with pip, either globally or in a virtual environment
E.g.
pip install numpy
The python packages need to be installed with pip, either globally or in a virtual environment
E.g.
pip install numpy
Just tried that, doesn't seem to work though:
PS C:\Users\---\Documents\js-projects\do-it-lol> pip install keyboard
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
Requirement already satisfied: keyboard in c:\python39\lib\site-packages (0.13.5)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
PS C:\Users\---\Documents\js-projects\do-it-lol> node .
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[🐍 Python Error Call to 'python' failed:
> const kb = await python('keyboard')
at async main (C:\Users\---\Documents\js-projects\do-it-lol\index.js:4:14)
... across the bridge ...
> return _bootstrap._gcd_import(name[level:], package, level)
at import_module (C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\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)
🌉 ModuleNotFoundError: No module named 'keyboard']
Looks like you have two Python installations installed, one in c:\python39
and another in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0
. Pip is installing to the former, but python
points to the latter.
You need to update the PATH env var to prioritize the Python install to c:\python39