Setting Up Jupyter Notebook with Scientific Python on RISC-V (Tested on Megrez)

1. Install System Dependencies

First install essential build tools and libraries:

sudo apt update

sudo apt install -y python3-pip python3-dev python3-venv \

build-essential libopenblas-dev liblapack-dev gfortran \

pkg-config libfreetype6-dev libpng-dev libjpeg-dev

Key Packages:

- `build-essential` – Provides GCC/make for compiling Python extensions

- `libopenblas-dev` – Optimized math library for NumPy/SciPy

- `libjpeg-dev` – Required for Matplotlib’s image support

  1. Create a Python Virtual Environment

Isolate your setup from system Python:

python3 -m venv ~/py-riscv

source ~/py-riscv/bin/activate

3. Install Jupyter Notebook

Start with the notebook core:

pip install --upgrade pip setuptools wheel

pip install notebook

4. Install Scientific Python Packages

Important: On RISC-V, these will compile from source (no pre-built wheels):

pip install numpy scipy matplotlib

What to Expect:

- Compilation will take significant time (30-60 mins on Megrez)

- Requires about 1GB of free disk space

- No progress bars during compilation – be patient

About Wheels:

Wheels (`.whl` files) are pre-compiled Python packages. Most repositories don’t yet provide RISC-V wheels, so pip must compile everything locally.

5. Launch Jupyter on Your Network

Run the notebook server accessible to other devices:

jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser

Access Instructions:

1. Find your Megrez board’s IP: `hostname -I`

2. From another computer, visit: `http://<MEGREZ_IP>:8888`

3. Enter the token shown in your terminal

Verified Compatibility

This configuration works on:

- Megrez (Debian-based RISC-V)

Performance Note:

First-time imports of NumPy/SciPy will be slow as they complete final optimizations. Subsequent runs will be faster.

Troubleshooting

If Matplotlib/Pillow installation fails:

1. Verify `libjpeg-dev` and `libfreetype6-dev` are installed

2. Retry with: `pip install --no-cache-dir matplotlib`

3 Likes