Use of Python Packages

Install and uninstall packages.

import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "polars"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "databpy"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "nodebpy"])
Collecting polars
  Using cached polars-2.0.0-py3-none-any.whl.metadata (11 kB)
Requirement already satisfied: polars-runtime-32==2.0.0 in ./Applications/Blender.app/Contents/Resources/5.3/python/lib/python3.13/site-packages (from polars) (2.0.0)
Using cached polars-2.0.0-py3-none-any.whl (876 kB)
Installing collected packages: polars
Successfully installed polars-2.0.0
Requirement already satisfied: databpy in ./Applications/Blender.app/Contents/Resources/5.3/python/lib/python3.13/site-packages (0.10.1)
Requirement already satisfied: numpy in ./Applications/Blender.app/Contents/Resources/5.3/python/lib/python3.13/site-packages (from databpy) (2.3.4)
[notice] A new release of pip is available: 26.0.1 -> 26.2.1

[notice] To update, run: /Applications/Blender.app/Contents/Resources/5.3/python/bin/python3.13 -m pip install --upgrade pip



[notice] A new release of pip is available: 26.0.1 -> 26.2.1

[notice] To update, run: /Applications/Blender.app/Contents/Resources/5.3/python/bin/python3.13 -m pip install --upgrade pip
Requirement already satisfied: nodebpy in ./Applications/Blender.app/Contents/Resources/5.3/python/lib/python3.13/site-packages (520.35.1)
[notice] A new release of pip is available: 26.0.1 -> 26.2.1

[notice] To update, run: /Applications/Blender.app/Contents/Resources/5.3/python/bin/python3.13 -m pip install --upgrade pip
0
# non-interactive uninstall  from Blender’s Python
subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "polars"])
Found existing installation: polars 2.0.0
Uninstalling polars-2.0.0:
  Successfully uninstalled polars-2.0.0
0
#On MacOS, if uv is installed via homebrew:
command = [
    "UV_PYTHON=python3.11",
    "/opt/homebrew/bin/uv", "pip", "install",
    "--prefix", "/Applications/Blender.app/Contents/Resources/4.3/python/",
    "matplotlib"
]
subprocess.run(" ".join(command), shell=True)
Using CPython 3.11.10

Checked 1 package in 19ms
CompletedProcess(args='UV_PYTHON=python3.11 /opt/homebrew/bin/uv pip install --prefix /Applications/Blender.app/Contents/Resources/4.3/python/ matplotlib', returncode=0)
# version check
import importlib.metadata

print("Databpy version:", importlib.metadata.version("databpy"))
Databpy version: 0.10.0
# version check
print("Nodbpy version:", importlib.metadata.version("nodebpy"))
Nodbpy version: 520.35.1