Automatically finds and adds Binary Ninja's Python API to sys.path at interpreter startup — no manual path manipulation needed.
pip install binaryninja-finder
Or with uv:
uv add binaryninja-finder
Once installed, import binaryninja will work in any script or REPL that uses the same Python environment.
The package installs a .pth file that runs automatically when Python starts. It checks whether binaryninja is already importable and, if not, searches for a local Binary Ninja installation and adds its python/ directory to sys.path.
The search order is:
BN_INSTALL_DIRenvironment variable — points to the BN installation rootlastrunfile — in the BN user config directory (written by Binary Ninja on launch)- Common platform paths — e.g.
/Applications/Binary Ninja.appon macOS,/opt/binaryninjaon Linux,C:\Program Files\Vector35\BinaryNinjaon Windows
| Environment variable | Description |
|---|---|
BN_INSTALL_DIR |
Override the Binary Ninja installation directory |
BN_USER_DIRECTORY |
Override the Binary Ninja user config directory (where lastrun is stored) |
You can also use the finder directly:
from binaryninja_finder._finder import find_binary_ninja
path = find_binary_ninja()
if path:
print(f"Found Binary Ninja Python API at: {path}")See LICENSE for details.