Registry / ai-ml / bittensor

bittensor

JSON →
library10.4.1pypypi✓ verified 89d ago

Python SDK for the Bittensor decentralized machine learning network. Allows interaction with the Bittensor blockchain, manage wallets, stake, register neurons, and query the metagraph. Version 10.2.1 is the current stable release. The library is actively maintained with frequent releases.

pip install bittensor
INSTALL
IMPORT
SIG · BITTENSOR
B
bittensor
ai-mlpythonv10.4.1
Install
12.0s avg
Import
3208ms
Disk
200MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v10.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 15.1s
py 3.11
✕ build_error
✓ 11.9s
py 3.12
✕ build_error
✓ 10.1s
py 3.13
✕ build_error
✓ 10.8s
py 3.9
✕ build_error
✕ build_error
200MB installed
● package 200MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bt
✓ import bittensor as bt
✗ from bittensor import bt
The module itself is bittensor, not bittensor.bt. Use import bittensor as bt.
Wallet
✓ from bittensor import Wallet
✗ from bittensor.wallet import Wallet
In v10+, Wallet is exported from the top-level bittensor module.
Subtensor
✓ from bittensor import subtensor
✗ from bittensor.subtensor import Subtensor
Use bittensor.subtensor (function) to get a Subtensor instance. Direct import of Subtensor class is discouraged.

Connects to the Bittensor test network, creates/generates a wallet, and prints the subnet 1 metagraph and balance.

import bittensor as bt # Connect to the network (finney testnet or mainnet) subtensor = bt.subtensor(network='test') # Create a wallet (will prompt for password if new) wallet = bt.Wallet(name='test-wallet') # Get the metagraph for subnet 1 metagraph = subtensor.metagraph(1) print('Subnet 1 metagraph:', metagraph) # Check hotkey balance balance = subtensor.get_balance(wallet.coldkeypub.ss58_address) print('Balance:', balance)
btcli --version
Debug
Known issues
breakingIn v10.0.0, many APIs were restructured. The old bittensor.bittensor and bittensor.utils modules are removed. Use bittensor.core instead.
fix
Update imports: from bittensor.core import ... instead of bittensor.bittensor.
affects: >=10.0.0
breakingThe 'max_retries' parameter was renamed to 'max_attempts' in v10.0.0rc3. Using the old name will cause a TypeError.
fix
Rename max_retries to max_attempts in your code.
affects: >=10.0.0rc3
gotchaWhen using bt.subtensor() to get a Subtensor instance, you must specify the 'network' argument. Failing to do so uses 'finney' (mainnet) by default, which may incur fees.
fix
Always pass network='test' for testnet or network='local' for local nodes.
affects: all
deprecatedThe 'bt.bittensor' module is deprecated. Use 'bt.core' for internal SDK functions.
fix
Replace bt.bittensor with bt.core in imports.
affects: >=10.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'bittensor.bittensor'
In v10+, the module structure changed. The old bittensor.bittensor module is removed.
fix
Use import bittensor as bt and access bittensor.core instead.
TypeError: __init__() got an unexpected keyword argument 'max_retries'
The 'max_retries' parameter was renamed to 'max_attempts' in v10.0.0rc3.
fix
Replace max_retries with max_attempts in the call.
bittensor.errors.NetworkError: Cannot connect to network 'finney'
The default network 'finney' may be unreachable or require correct endpoint configuration.
fix
Specify a valid network like 'test' or set environment variable BITTENSOR_NETWORK.
Upgrade
Version history
10.4.1latest on PyPI · released Jun 11, 2026
Audit
Dependencies
numpyrequiredUsed for tensor operations and numerical computations.
torchoptionalRequired for PyTorch tensor support (common in miner/validator code).
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
bittensor — pip install bittensor · libregistry