A Deno Python wrapper that supports using virtual environments like from uv.
This lets you easily call Python modules from Deno code: in a portable, simple, and low setup way.
jsr:@orgsoft/py is based on
jsr:@denosaurs/python and its native
Python/C bindings. You can read more about that and further documentation on
their GitHub repo.
There are two ways to use this module, either from code or command-line.
This is the recommended way to use this module.
import{getPython}from"jsr:@orgsoft/py";const{ python }=awaitgetPython();// Import a module and run a functionconstmodule=awaitpython.import("my_module");constresult=awaitmodule.main();console.log(result);// Run raw python codepython.run("print('hello world'));
// Continued...constnp=python.import("numpy");constplt=python.import("matplotlib.pyplot");constxpoints=np.array([1,8]);constypoints=np.array([3,10]);plt.plot(xpoints,ypoints);plt.show();This isn't particularly useful aside for testing, as you're better off using
python run or uv run directly. But, maybe someone needs it..
deno run --allow-ffi --allow-env --allow-read --allow-run jsr:@orgsoft/py <python_module>You could also install @orgsoft/py so it can be accessed quickly:
deno install -frAg --name denopy jsr:@orgsoft/py/mod.ts
denopy my_python_moduleReplace denopy with any alias name you'd like.
Deno must be installed to use.
You should source a virtual environment to properly use @orgsoft/py:
source .venv/bin/activateIf you are using a different venv path, run:
source {MY_PYTHON_PROJECT_PATH}/.venv/bin/activateWe recommend using uv to create your virtual
environment.
Then, run:
uv init
uv sync
source .venv/bin/activateto create and activate your virtual environment.
Go to example.
✌️