anggoran
anggoran12mo ago

deno_python

I'm trying to use Python with Deno with https://deno.land/x/python@0.2.7 What should I do to enable import Python 3rd party module, should I create Python venv?
14 Replies
ioB
ioB12mo ago
@load1n9
loading...
loading...12mo ago
if you install the 3rd party extension to the used python version it should work
anggoran
anggoran12mo ago
Is it like running a venv inside the Deno project?
loading...
loading...12mo ago
nope its bindings to your installed python version
anggoran
anggoran12mo ago
Oh so I need to install say, pandas globally?
loading...
loading...12mo ago
yep
anggoran
anggoran12mo ago
I see, thank youu
rajsite
rajsite12mo ago
Another thing to try could be using python via pyodide. With deno's npm and --node-modules-dir support I found you can leverage pyodide and the libraries compiled for it (the example there shows numpy): https://github.com/pyodide/pyodide/issues/3420#issuecomment-1542742906
GitHub
Deno support · Issue #3420 · pyodide/pyodide
Deno support was discussed in #1477 (comment) and I think it would be good to add it and have some minimal tests in CI. As discussed in the linked PR only a few minor fixes are needed. I'll ope...
ioB
ioB12mo ago
deno_python supports all python modules because it just talks to the interpreter, I feel like these are different use cases for sure
rajsite
rajsite12mo ago
Seems like the use case is pretty similar, leverage some python libraries and code in a deno app, but the tradeoffs in implementation are different, python that runs inside the deno sandbox as webassembly vs global / system installed python. There is a fair number of libraries available in pyodide but true that it's not everything available on a system: https://pyodide.org/en/stable/usage/packages-in-pyodide.html
ioB
ioB12mo ago
fair enough
Snabel
Snabel12mo ago
There is a PR I made for installing and importing pip packages for deno_python too! https://github.com/denosaurs/deno_python/pull/43 I realized I need to fix some name normalization which I have on my other computer so you will have to wait a little longer but it uses the same environment as python so if sys.path in python contains the venv lib path it uses venv. (my pr does some magic and adds a deno path to the sys.path)
ioB
ioB12mo ago
thanks for the update eliass