2021-04-28 14:38:14 -07:00
---
2022-10-31 11:13:15 -07:00
id: installation
2022-11-02 14:50:50 -07:00
title: Meshtastic Python CLI installation
2021-04-28 14:38:14 -07:00
sidebar_label: Installation
2022-11-02 14:50:50 -07:00
slug: /software/python/cli/installation
2022-10-31 10:27:04 -07:00
sidebar_position: 1
2024-03-16 00:10:18 -07:00
description: This page offers comprehensive instructions on methods of installing the Meshtastic Python CLI across different operating systems.
2021-04-28 14:38:14 -07:00
---
2022-03-08 23:10:41 -08:00
2023-01-19 05:01:57 -08:00
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
2021-04-28 14:38:14 -07:00
2024-03-15 23:10:30 -07:00
## Meshtastic Python Library
2021-04-28 14:38:14 -07:00
2024-03-15 23:10:30 -07:00
This library provides a command-line interface (CLI) for managing the user settings of Meshtastic nodes and provides an easy API for sending and receiving messages over mesh radios. Events are delivered using a publish-subscribe model, and you can subscribe to only the message types you are interested in.
2021-04-28 14:38:14 -07:00
2024-03-15 23:10:30 -07:00
The [Meshtastic-python repo](https://github.com/meshtastic/Meshtastic-python) and [API documentation](https://python.meshtastic.org) are excellent sources of information. If you wish to view the code or contribute to the development of the Python library or the command-line interface, please visit the Meshtastic Python [GitHub page](https://github.com/meshtastic/Meshtastic-python).
2021-06-04 17:14:02 -07:00
2024-03-15 23:10:30 -07:00
### Prerequisites
Before installing, ensure that your system meets the following requirements:
- **Serial Drivers**: Your computer should have the required serial drivers installed for the [CP210X USB to UART bridge](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) or the [CH9102](http://www.wch.cn/downloads/CH343SER_ZIP.html) (for some newer boards).
- **Python**: Python 3 should be installed on your system. Check with `python3 -V` and install it if necessary.
- **pip**: The Python package installer pip should be installed. Check with `pip3 -V` and install it if necessary.
After ensuring the requirements are met, follow the installation instructions for your operating system in the tabbed section below.
2021-11-23 11:36:32 -08:00
2024-03-16 10:51:00 -07:00
### Installation Instructions
2021-04-28 14:38:14 -07:00
2021-05-15 11:36:15 -07:00
<Tabs
2022-03-08 23:10:41 -08:00
groupId="operating-system"
2024-03-15 23:10:30 -07:00
queryString="install-python-cli"
defaultValue="windows"
2022-03-08 23:10:41 -08:00
values={[
{label: 'Linux', value: 'linux'},
{label: 'macOS', value: 'macos'},
{label: 'Windows', value: 'windows'},
{label: 'Termux for Android', value: 'termux'},
]}>
2021-05-15 11:45:05 -07:00
<TabItem value="linux">
2021-05-15 11:49:53 -07:00
2024-02-22 13:09:26 -08:00
#### Linux
2022-03-08 23:10:41 -08:00
- Check that your computer has the required serial drivers installed
- Connect your Meshtastic device to your USB port
- Use the command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
lsusb
```
- You should see something like:
- `ID 10c4:ea60 Silicon Labs CP210x UART Bridge` for CP210X
- `ID 1a86:55d4 QinHeng Electronics USB Single Serial` for CH9102
- Check that your computer has Python 3 installed.
- Use the command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
python3 -V
```
- If this does not return a version, install python
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
sudo apt-get update
sudo apt-get install python3
```
- Pip is typically installed if you are using python 3 version >= 3.4
- Check that pip is installed using this command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
pip3 -V
```
- If this does not return a version, install pip
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
sudo apt-get install python3-pip
```
- Optional: use a python virtual environment (otherwise jump to step "Install pytap2")
- Install python-virtualenvwrapper (arch based distros as an example)
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
sudo pacman -Syu python-virtualenvwrapper
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- Create a virtual environment
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
source /usr/bin/virtualenvwrapper.sh
mkvirtualenv meshtastic
workon meshtastic
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- Install pytap2
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
pip3 install --upgrade pytap2
```
- Install meshtastic:
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
pip3 install --upgrade meshtastic
```
2021-05-15 11:49:53 -07:00
2021-05-15 11:45:05 -07:00
</TabItem>
<TabItem value="macos">
2021-05-15 11:49:53 -07:00
2024-02-22 13:09:26 -08:00
#### macOS
2022-03-08 23:10:41 -08:00
- Check that your computer has the required serial drivers installed
- Connect your Meshtastic device to your USB port
- Navigate to `Apple Menu > About This Mac > System Report... > Hardware > USB`
- You should see something like `CP210X USB to UART Bridge Controller`
- If not download the drivers from [Silicon Labs](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers).
- Check that your computer has Python 3 installed.
- Use the command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
python3 -V
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- If this does not return a version, install [python](https://www.python.org)
- The following uses Homebrew to install `python3` which includes `pip3`.
- Check if you have Homebrew installed with the following command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
brew -v
```
If it's not installed, follow the instructions on the [Homebrew website](https://brew.sh) before continuing.
- Install Python3
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
brew install python3
```
- Pip is typically installed if you are using python 3 version >= 3.4
- Check that pip is installed using this command
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
pip3 -V
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- If this does not return a version, install [pip](https://pip.pypa.io/en/stable/installing)
- Install pytap2
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
sudo pip3 install --upgrade pytap2
```
- Install meshtastic:
2022-04-01 06:34:49 -07:00
```shell
2022-03-08 23:10:41 -08:00
sudo pip3 install --upgrade meshtastic
```
2021-05-15 11:49:53 -07:00
2021-05-15 11:45:05 -07:00
</TabItem>
<TabItem value="windows">
2021-05-15 11:49:53 -07:00
2024-02-22 13:09:26 -08:00
#### Windows
2022-03-08 23:10:41 -08:00
- Check that your computer has the required serial drivers installed
- Connect your Meshtastic device to your USB port
- Open Device Manager
- Under `Ports (COM & LPT)` you should see something like `Silicon Labs CP210X USB to UART Bridge (COM5)`
- If not download the drivers from [Silicon Labs](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers) or use the direct link below.
2021-10-24 11:11:55 -07:00
:::warning
You must install the [CP210x Universal Windows Driver](https://www.silabs.com/documents/public/software/CP210x_Universal_Windows_Driver.zip). If you do not install this driver, your device may not work and the driver may need to be uninstalled from device manager before installing the correct driver.
:::
2022-03-08 23:10:41 -08:00
- Check that your computer has Python 3 installed.
- Use the command
2021-05-15 11:45:05 -07:00
```powershell
2022-03-08 23:10:41 -08:00
py -V
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- If this does not return a version, install [python](https://www.python.org)
- Pip is typically installed if you are using python 3 version >= 3.4
- Check that pip is installed using this command
2021-05-15 11:45:05 -07:00
```powershell
2022-03-08 23:10:41 -08:00
pip3 -V
2021-05-15 11:45:05 -07:00
```
2022-03-08 23:10:41 -08:00
- If this does not return a version, install [pip](https://pip.pypa.io/en/stable/installing)
- Install pytap2
```powershell
pip3 install --upgrade pytap2
```
- Install meshtastic:
```powershell
pip3 install --upgrade meshtastic
```
2021-11-23 11:36:32 -08:00
2021-06-04 17:14:02 -07:00
</TabItem>
<TabItem value="termux">
2021-06-04 17:27:07 -07:00
2024-02-22 13:09:26 -08:00
#### Termux
2021-10-24 11:11:55 -07:00
:::note
2022-04-08 08:03:47 -07:00
Wifi connection is currently under development and may not be working properly just yet. If you would like to provide feedback or test this feature, please visit our [forum](https://meshtastic.discourse.group) or join our [Discord server](https://discord.gg/ktMAKGBnBs) for more information.
2021-10-24 11:11:55 -07:00
:::
2022-03-08 23:10:41 -08:00
- Install [Termux](https://f-droid.org/en/packages/com.termux) from the F-Droid app store (Google play does not currently support the latest builds)
- Load Termux and update the package list
2023-01-19 05:01:57 -08:00
```shell
2022-03-08 23:10:41 -08:00
pkg update
```
- Upgrade the installed packages
2023-01-19 05:01:57 -08:00
```shell
2022-03-08 23:10:41 -08:00
pkg upgrade
```
- Install python
2023-01-19 05:01:57 -08:00
```shell
2022-03-08 23:10:41 -08:00
pkg install python
```
- Upgrade pip and installed meshtastic and some of its dependencies
2023-01-19 05:01:57 -08:00
```shell
2023-06-09 17:16:03 -07:00
pip install --upgrade pip pygatt pytap2 wheel meshtastic
2022-03-08 23:10:41 -08:00
```
2021-06-04 17:14:02 -07:00
2021-12-29 10:49:34 -08:00
:::note
2021-12-27 11:39:42 -08:00
Be aware that the Meshtastic CLI is not able to control the nodes over USB through termux, but you can control devices over Wifi using the `--host x.x.x.x` option with the device IP address. However, only ESP32 devices can use Wifi currently.
2021-06-04 17:14:02 -07:00
:::
2022-04-01 06:34:49 -07:00
2021-05-15 11:45:05 -07:00
</TabItem>
2021-09-13 23:27:12 -07:00
</Tabs>
2021-11-09 18:41:38 -08:00
:::info
You may need to close and re-open the CLI. The path variables may or may not update for the current session when installing.
2021-11-23 11:36:32 -08:00
:::
2022-11-02 14:50:50 -07:00
2024-03-15 23:10:30 -07:00
### Standalone Installation (Ubuntu only)
2022-11-02 14:50:50 -07:00
2024-03-15 23:10:30 -07:00
1. Download the `meshtastic_ubuntu` executable from the [Releases](https://github.com/meshtastic/Meshtastic-python/releases) page.
2. Run the following command to make the file executable and rename it `meshtastic`:
2022-11-02 14:50:50 -07:00
2023-01-19 05:01:57 -08:00
```shell
2022-11-02 14:50:50 -07:00
chmod +x meshtastic_ubuntu && mv meshtastic_ubuntu meshtastic
```
2024-03-15 23:10:30 -07:00
3. To run the CLI:
2022-11-02 14:50:50 -07:00
2023-01-19 05:01:57 -08:00
```shell
2022-11-02 14:50:50 -07:00
./meshtastic
```
:::tip
Copy (or move) this binary somewhere in your path.
:::