deno_python
Python interpreter bindings for Deno.
Example
Import any locally installed Python package, for example, matplotlib
:
import { python } from "https://deno.land/x/python/mod.ts";
const np = python.import("numpy");
const plt = python.import("matplotlib.pyplot");
const xpoints = np.array([1, 8]);
const ypoints = np.array([3, 10]);
plt.plot(xpoints, ypoints);
plt.show();
When running, you must specify --allow-ffi
, --allow-env
and --unstable
flags. Alternatively, you may also just specify -A
instead of specific
permissions since enabling FFI effectively escapes the permissions sandbox.
deno run -A --unstable <file>
Documentation
Check out the docs here.
Python Installation
This module uses FFI to interface with the Python interpreter's C API. So you
must have an existing Python installation (with the shared library), which is
something like python310.dll
, etc.
Python installed from Microsoft Store does not work, as it does not contain shared library for interfacing with Python interpreter.
If the module fails to find Python, you can add the path to the Python in the
DENO_PYTHON_PATH
environment variable.
DENO_PYTHON_PATH
if set, must point to full path including the file name of
the Python dynamic library, which is like python310.dll
(Windows),
libpython310.dylib
(macOS) and libpython310.so
(Linux) depending on
platform.
Maintainers
- DjDeveloper (@DjDeveloperr)
- Elias Sjรถgreen (@eliassjogreen)
Other
Contribution
Pull request, issues and feedback are very welcome. Code style is formatted with
deno fmt
and commit messages are done following Conventional Commits spec.
Licence
Copyright 2021, DjDeveloperr.
Copyright 2023, the Denosaurs team. All rights reserved. MIT license.