{"id":21005,"library":"bittensor","title":"Bittensor Python SDK","description":"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.","status":"active","version":"10.2.1","language":"python","source_language":"en","source_url":"https://github.com/opentensor/bittensor","tags":["bittensor","blockchain","machine-learning","decentralized","neural-network","mining","crypto"],"install":[{"cmd":"pip install bittensor","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for tensor operations and numerical computations.","package":"numpy","optional":false},{"reason":"Required for PyTorch tensor support (common in miner/validator code).","package":"torch","optional":true}],"imports":[{"note":"The module itself is bittensor, not bittensor.bt. Use import bittensor as bt.","wrong":"from bittensor import bt","symbol":"bt","correct":"import bittensor as bt"},{"note":"In v10+, Wallet is exported from the top-level bittensor module.","wrong":"from bittensor.wallet import Wallet","symbol":"Wallet","correct":"from bittensor import Wallet"},{"note":"Use bittensor.subtensor (function) to get a Subtensor instance. Direct import of Subtensor class is discouraged.","wrong":"from bittensor.subtensor import Subtensor","symbol":"Subtensor","correct":"from bittensor import subtensor"}],"quickstart":{"code":"import bittensor as bt\n\n# Connect to the network (finney testnet or mainnet)\nsubtensor = bt.subtensor(network='test')\n\n# Create a wallet (will prompt for password if new)\nwallet = bt.Wallet(name='test-wallet')\n\n# Get the metagraph for subnet 1\nmetagraph = subtensor.metagraph(1)\nprint('Subnet 1 metagraph:', metagraph)\n\n# Check hotkey balance\nbalance = subtensor.get_balance(wallet.coldkeypub.ss58_address)\nprint('Balance:', balance)","lang":"python","description":"Connects to the Bittensor test network, creates/generates a wallet, and prints the subnet 1 metagraph and balance."},"warnings":[{"fix":"Update imports: from bittensor.core import ... instead of bittensor.bittensor.","message":"In v10.0.0, many APIs were restructured. The old bittensor.bittensor and bittensor.utils modules are removed. Use bittensor.core instead.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Rename max_retries to max_attempts in your code.","message":"The 'max_retries' parameter was renamed to 'max_attempts' in v10.0.0rc3. Using the old name will cause a TypeError.","severity":"breaking","affected_versions":">=10.0.0rc3"},{"fix":"Always pass network='test' for testnet or network='local' for local nodes.","message":"When 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace bt.bittensor with bt.core in imports.","message":"The 'bt.bittensor' module is deprecated. Use 'bt.core' for internal SDK functions.","severity":"deprecated","affected_versions":">=10.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import bittensor as bt and access bittensor.core instead.","cause":"In v10+, the module structure changed. The old bittensor.bittensor module is removed.","error":"ModuleNotFoundError: No module named 'bittensor.bittensor'"},{"fix":"Replace max_retries with max_attempts in the call.","cause":"The 'max_retries' parameter was renamed to 'max_attempts' in v10.0.0rc3.","error":"TypeError: __init__() got an unexpected keyword argument 'max_retries'"},{"fix":"Specify a valid network like 'test' or set environment variable BITTENSOR_NETWORK.","cause":"The default network 'finney' may be unreachable or require correct endpoint configuration.","error":"bittensor.errors.NetworkError: Cannot connect to network 'finney'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}