Skip to main content
SUBMIT A PRSUBMIT AN ISSUElast edit: Oct 17, 2024

Install Bittensor SDK

Before you can start developing, you must install Bittensor SDK and then create Bittensor wallet.

Upgrade

If you already installed Bittensor SDK, make sure you upgrade to the latest version. Run the below command:

python3 -m pip install --upgrade bittensor

Developer reference

For a full developer reference, see the Bittensor SDK section.

Install on macOS and Linux

You can install Bittensor on your local machine in either of the following ways. Make sure you verify your installation after you install.

Install using a Bash command

This is the most straightforward method. It is recommended for a beginner as it will pre-install requirements like Python, if they are not already present on your machine. Copy and paste the following bash command into your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh)"
For Ubuntu-Linux users

If you are using Ubuntu-Linux, the script will prompt for sudo access to install all required apt-get packages.

Create and activate a virtual environment

Install Python virtual environment

python3 -m venv btsdk_venv
source btsdk_venv/bin/activate

Install from source

  1. Clone the Bittensor repo
git clone https://github.com/opentensor/bittensor.git
  1. Change to the Bittensor directory:
cd bittensor
  1. Install
  • Install SDK: Run the below command to install Bittensor SDK in the above virtual environment. This will also install btcli.
pip install .
  • Install SDK with torch: Install Bittensor SDK with torch.

     pip install bittensor[torch]

    In some environments the above command may fail, in which case run the command with added quotes as shown below:

      pip install "bittensor[torch]"

Install from PyPi

You can install Bittensor using any of the below options:

  • Install SDK: Run the below command to install Bittensor SDK in the above virtual environment. This will install btcli also.
pip install bittensor
  • Install SDK with torch: Install Bittensor SDK with torch.

     pip install bittensor[torch]

    In some environments the above command may fail, in which case run the command with added quotes as shown below:

      pip install "bittensor[torch]"
  • Install SDK with cubit: Install Bittensor SDK with cubit.

    1. Install cubit first. See the Install section. Only Python 3.9 and 3.10 versions are supported.
    2. Then install SDK with pip install bittensor.

Install on Windows

To install and run Bittensor SDK on Windows you must install WSL 2 (Windows Subsystem for Linux) on Windows and select Ubuntu Linux distribution.

After you installed the above, follow the same installation steps described above in Install on macOS and Linux.

Limited support on Windows

While wallet transactions like delegating, transfer, registering, staking can be performed on a Windows machine using WSL 2, the mining and validating operations are not recommended and are not supported on Windows machines.

Verify the installation

You can verify your installation in either of the two ways as shown below:

Verify using btsdk version

python3 -m bittensor
Bittensor SDK version: <version number>

The above command will show you the <version number> of the btsdk you just installed.

Verify using Python interpreter

  1. Launch the Python interpreter on your terminal.

    python3
  2. Enter the following two lines in the Python interpreter.

    import bittensor as bt
    print( bt.__version__ )

    The Python interpreter output will look like below:

    >>> print( bt.__version__ )
    <version number>

You will see the version number you installed in place of <version number>.

Verify by listing axon information

You can also verify the Bittensor installation by listing the axon information for the neurons. Enter the following lines in the Python interpreter.

import bittensor as bt
metagraph = bt.metagraph(1)
metagraph.axons[:10]

The Python interpreter output will look like below.

[AxonInfo( /ipv4/3.139.80.241:11055, 5GqDsK6SAPyQtG243hbaKTsoeumjQQLhUu8GyrXikPTmxjn7, 5D7u5BTqF3j1XHnizp9oR67GFRr8fBEFhbdnuVQEx91vpfB5, 600 ), AxonInfo( /ipv4/8.222.132.190:5108, 5CwqDkDt1uk2Bngvf8avrapUshGmiUvYZjYa7bfA9Gv9kn1i, 5HQ9eTDorvovKTxBc9RUD22FZHZzpy1KRfaxCnRsT9QhuvR6, 600 ), AxonInfo( /ipv4/34.90.71.181:8091, 5HEo565WAy4Dbq3Sv271SAi7syBSofyfhhwRNjFNSM2gP9M2, 5ChuGqW2cxc5AZJ29z6vyTkTncg75L9ovfp8QN8eB8niSD75, 601 ), AxonInfo( /ipv4/64.247.206.79:8091, 5HK5tp6t2S59DywmHRWPBVJeJ86T61KjurYqeooqj8sREpeN, 5E7W9QXNoW7se7B11vWRMKRCSWkkAu9EYotG5Ci2f9cqV8jn, 601 ), AxonInfo( /ipv4/51.91.30.166:40203, 5EXYcaCdnvnMZbozeknFWbj6aKXojfBi9jUpJYHea68j4q1a, 5CsxoeDvWsQFZJnDCyzxaNKgA8pBJGUJyE1DThH8xU25qUMg, 601 ), AxonInfo( /ipv4/149.137.225.62:8091, 5F4tQyWrhfGVcNhoqeiNsR6KjD4wMZ2kfhLj4oHYuyHbZAc3, 5Ccmf1dJKzGtXX7h17eN72MVMRsFwvYjPVmkXPUaapczECf6, 600 ), AxonInfo( /ipv4/38.147.83.11:8091, 5Hddm3iBFD2GLT5ik7LZnT3XJUnRnN8PoeCFgGQgawUVKNm8, 5DCQw11aUW7bozAKkB8tB5bHqAjiu4F6mVLZBdgJnk8dzUoV, 610 ), AxonInfo( /ipv4/38.147.83.30:41422, 5HNQURvmjjYhTSksi8Wfsw676b4owGwfLR2BFAQzG7H3HhYf, 5EZUTdAbXyLmrs3oiPvfCM19nG6oRs4X7zpgxG5oL1iK4MAh, 610 ), AxonInfo( /ipv4/54.227.25.215:10022, 5DxrZuW8kmkZPKGKp1RBVovaP5zHtPLDHYc5Yu82Z1fWqK5u, 5FhXUSmSZ2ec7ozRSA8Bg3ywmGwrjoLLzsXjNcwmZme2GcSC, 601 ), AxonInfo( /ipv4/52.8.243.76:40033, 5EnZN591jjsKKbt3yBtfGKWHxhxRH9cJonqTKRT5yTRUyNon, 5ChzhHyGmWwEdHjuvAxoUifHEZ6xpUjR67fDd4a42UrPysyB, 601 )]
>>>