Finds a local Binary Ninja installation so you can import binaryninja in Python. Running outside the GUI requires a license that supports headless use.
Add it to a project.
uv add binaryninja-finder
Try it without adding a project dependency.
uv run --with binaryninja-finder python -c 'import binaryninja; print(binaryninja.core_version())'
Save this as example.py.
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = ["binaryninja-finder"]
# ///
import binaryninja
print(binaryninja.core_version())
Run the script with uv.
uv run --script example.py
On systems that support shebangs, you can also run chmod +x example.py and then ./example.py.
- Set
BN_INSTALL_DIRto your Binary Ninja installation path if automatic discovery misses it. - Set
BN_USER_DIRECTORYif you use a custom Binary Ninja settings directory.