Meshtastic Python CLI installation
Meshtastic Python Library
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.
The Meshtastic-python repo is an excellent source 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.
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 or the CH9102 (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.
Installation Instructions
To install the Meshtastic CLI, select the tab for your operating system and follow the step-by-step instructions for installing via pip
. For Ubuntu only, you can alternatively install the Standalone version if you prefer.
- Linux
- macOS
- Windows
- Termux for Android
Linux
-
Check that your computer has the required serial drivers installed
- Connect your Meshtastic device to your USB port
- Use the command
lsusb
- You should see something like:
ID 10c4:ea60 Silicon Labs CP210x UART Bridge
for CP210XID 1a86:55d4 QinHeng Electronics USB Single Serial
for CH9102- If there is no seral device shown that matches the device you are using, please review our Install Serial Drivers page before proceeding.
-
Check that your computer has Python 3 installed.
- Use the command
python3 -V
- If this does not return a version, install python
sudo apt-get update
sudo apt-get install python3
- Use the command
-
Pip is typically installed if you are using python 3 version >= 3.4
- Check that pip is installed using this command
pip3 -V
- If this does not return a version, install pip
sudo apt-get install python3-pip
- Check that pip is installed using this command
-
Optional: use a python virtual environment (otherwise jump to step "Install pytap2")
- Install python-virtualenvwrapper (arch based distros as an example)
sudo pacman -Syu python-virtualenvwrapper
- Create a virtual environment
source /usr/bin/virtualenvwrapper.sh
mkvirtualenv meshtastic
workon meshtastic
- Install python-virtualenvwrapper (arch based distros as an example)
-
Install pytap2
pip3 install --upgrade pytap2
-
Install meshtastic:
pip3 install --upgrade "meshtastic[cli]"
(the
[cli]
suffix installs a few optional dependencies that match older versions of the CLI)- Using pipx as an alternative to pip3 if
externally-managed-environment
error is encounteredsudo apt install pipx && pipx install "meshtastic[cli]"
- If using
pipx
it may be necessary to update$PATH
by running:pipx ensurepath
- If using
- Using pipx as an alternative to pip3 if
macOS
-
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 there is no serial device shown that matches the device you are using, please review our Install Serial Drivers page before proceeding.
-
Check that your computer has Python 3 installed.
- Use the command
python3 -V
- If this does not return a version, install python
- The following uses Homebrew to install
python3
which includespip3
. - Check if you have Homebrew installed with the following command
If it's not installed, follow the instructions on the Homebrew website before continuing.
brew -v
- Install Python3
brew install python3
- The following uses Homebrew to install
- Use the command
-
Pip is typically installed if you are using python 3 version >= 3.4
- Check that pip is installed using this command
pip3 -V
- If this does not return a version, install pip
- Check that pip is installed using this command
-
Install pipx
brew install pipx
pipx ensurepath -
Install meshtastic:
pipx install "meshtastic[cli]"
(the
[cli]
suffix installs a few optional dependencies that match older versions of the CLI)