Skip to content

Latest commit

 

History

History
97 lines (71 loc) · 5 KB

GNU Radio Install Guide.md

File metadata and controls

97 lines (71 loc) · 5 KB

GNURadio with Anaconda Python 3 Installation Guide

At its current state, GNURadio 3.7 does not work out-of-the-box with Python 3. This is a guide to building GNURadio from source to use a Python 3 Anaconda environment. This setup is particularly nice since you can still easily import other Python packages with conda and use them inside GNURadio blocks.

The Easy Way

Just run our super helpful installation script. It's as easy as: ./install.sh. It will check for the right dependencies (conda and various system packages), install them if needed, check out GNU Radio, build and install it to the right location, and add the right environment variables to ~/.bashrc so you can get started right away.

The Hard Way

Read this guide and follow along. The most up-to-date and correct version of the installation procedure is actually in ./install.sh, so you may want to compare for reference. However, this version provides some valuable explanations.

This guide assumes you have installed all the system dependencies of GNURadio (not including the Python ones) and Anaconda 3. You can find the list of system dependencies on the GNURadio website. You need all the ones that aren't called gnuradio or python-*.

Installing Anaconda (or Miniconda)

First, we need to install miniconda. Download the installation script from their website and run it.

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

GNURadio Dependencies

From their installation guide, install the following dependencies. Some are for python not from the system PM. Don't install these, they are included in the conda environment.

sudo apt-get update && sudo apt-get install git cmake libboost-all-dev libcppunit-dev liblog4cpp5-dev

Pulling the Source

Pull the GNURadio source and the environment.yml file that describes the conda environment that plays nice with GNURadio. At the time that this tutorial was written, this worked for 72aa97d.

git clone --recurse-submodules https://github.com/gnuradio/gnuradio
cd gnuradio
wget https://gist.githubusercontent.com/rytse/dd66e066b4b218022ac111e4a3618660/raw/66aca50cc7a66e0f212301f8e700402a0a6acf7c/gr_py3_env.yml

Installation

Create the conda environment (the one described by the yml file is called "dsp") and build GNURadio using the Python interpreter and libraries in the conda environment.

conda env create -f gr_py3_env.yml
conda activate dsp
mkdir build
cd build
cmake -DPYTHON_EXECUTABLE=$CONDA_PREFIX/envs/dsp/bin/python3.7 -DPYTHON_INCLUDE_DIR=$CONDA_PREFIX/envs/dsp/include/python3.7m -DPYTHON_LIBRARY=$CONDA_PREFIX/envs/dsp/lib/libpython3.7m.so -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX/envs/dsp ../
make -j$(nproc)
sudo make install
sudo ldconfig

Configuring Path to GNURadio's Python Libs

By default, make installs to -DCMAKE_INSTALL_PREFIX/libs/<python version>/dist-packages/, but the conda Python interpreter looks for packages in <prefix>/libs/<python version>/site-packages/. Thus, we symlink to the packages installed.

ln -s $CONDA_PREFIX/envs/dsp/lib/python3.7/dist-packages $CONDA_PREFIX/envs/dsp/lib/python3.7/site-packages

And that's it. You should now be able to import GNURadio from (dsp) and run grc blocks written in (dsp).

Configuring environment variables

We set GNU_RADIO_PATH for future reference. We add QT and the gnuradio binaries to our path. We add qt and GNU Radio shared libraries, pkgconfig, and we finally add GNU Radio python packages to PYTHONPATH.

export GNU_RADIO_PATH=$INSTALL_DIR
export PATH=/opt/qt/bin:\$PATH:$INSTALL_DIR/bin
export LD_LIBRARY_PATH=/opt/qt/lib:/usr/local/lib:\$LD_LIBRARY_PATH:$INSTALL_DIR/lib
export PKG_CONFIG_PATH=/opt/qt/lib/pkgconfig:\$PKG_CONFIG_PATH:$INSTALL_DIR/lib/pkgconfig
export PYTHONPATH=$PYTHONPATH:$CONDA_PREFIX/envs/dsp/lib/python3.7/dist-packages

Running GRC with examples

Open ~/miniconda3/envs/dsp/share/gnuradio/examples