Use of Python Packages¶
Install and uninstall packages.
In [127]:
Copied!
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "polars"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "databpy"])
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "polars"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "databpy"])
Collecting polars Using cached polars-1.29.0-cp39-abi3-macosx_11_0_arm64.whl.metadata (14 kB) Using cached polars-1.29.0-cp39-abi3-macosx_11_0_arm64.whl (31.1 MB) Installing collected packages: polars Successfully installed polars-1.29.0
[notice] A new release of pip is available: 24.0 -> 25.1.1 [notice] To update, run: /Applications/Blender.app/Contents/Resources/4.4/python/bin/python3.11 -m pip install --upgrade pip
Requirement already satisfied: databpy in /Applications/Blender.app/Contents/Resources/4.4/python/lib/python3.11/site-packages (0.0.18) Requirement already satisfied: numpy<2.0,>=1.24.0 in /Applications/Blender.app/Contents/Resources/4.4/python/lib/python3.11/site-packages (from databpy) (1.26.4)
[notice] A new release of pip is available: 24.0 -> 25.1.1 [notice] To update, run: /Applications/Blender.app/Contents/Resources/4.4/python/bin/python3.11 -m pip install --upgrade pip
Out[127]:
0
In [129]:
Copied!
import subprocess
import sys
# non-interactive uninstall from Blender’s Python
subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "polars"])
import subprocess
import sys
# non-interactive uninstall from Blender’s Python
subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "polars"])
WARNING: Skipping polars as it is not installed.
Out[129]:
0
In [130]:
Copied!
#On MacOS, if uv is installed via homebrew:
import subprocess
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)
#On MacOS, if uv is installed via homebrew:
import subprocess
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 interpreter at: .venv/bin/python3
Audited 1 package in 2ms
Out[130]:
CompletedProcess(args='UV_PYTHON=python3.11 /opt/homebrew/bin/uv pip install --prefix /Applications/Blender.app/Contents/Resources/4.3/python/ matplotlib', returncode=0)
In [ ]:
Copied!