Fresh Install Process on the Raspberry Pi, specifically for Developers.
-
Download the Raspberri Pi OS tool for flashing your SD card from The Raspberry Pi Foundation.
-
Plug in your SD card and use tghe tool to flash the 32-bit os to the card.
-
When the flasher finishes, remove the card and then place it back in.
-
Enable SSH
$ cd /Volumes/boot $ nano ssh
- Enter any text in the editor, then hit
ctrl + x
, theny
, thenENTER
- Enter any text in the editor, then hit
-
Enable WiFi
$ cd /Volumes/boot $ nano wpa_supplicant.conf
And then enter your wifi info as below:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=us network={ ssid="yourSSID" psk="Your_wireless_network_password" }
- hit
ctrl + x
, theny
, thenENTER
to exit
- hit
-
Eject your SD card, and put it into the pi, then power up the pi.
- Note: If you already have a raspberry pi running on your local network, and you haven't changed its hostname, you should power it off before connecting your new pi
-
Give it a second to connect to wiFi, then from your computer, connect to the pi:
ssh [email protected]
- Press
Y
to add the device to the list of known hosts - When prompted, enter the default password
raspberry
- Optionally, you can use ssh-copy-id to authenticate via an ssh key.
- Note: If you have already connected to another [email protected] from this computer, you may get a
Host key verification failed.
If this happens, simply edit yourknown_hosts
file and remove the line that begins withraspberrypi.local
- Use
nano ~/.ssh/known_hosts
and thenctrl + x
,y
,ENTER
as before - After editing the file, try again to connect via ssh
- Use
- Press
-
From the ssh connection, set up the pi by running
sudo raspi-config
0. Update - Probably already up to date, but might as well- System Options
- S3 Password: Change the password to something other than the default
raspberry
- S4 Hostname: Give your device a unique hostname, so you can connect to it at
<yourHostname>.local
on your network
- S3 Password: Change the password to something other than the default
- Display Options
- D1 Resolution: Choose DMT Mode 82 1920x1080 for normal HDMI displays
- Interface Options
- P1 Camera: Enable the camera if you need it
- P2 SSH: We've already enabled this
- P3 VNC: Enable VNC if you plan on using it
- Localisation Options
- L1 Locale: en_GB.UTF-8 is default, but set to what you want/need
- L2 Timezone: Set it as needed
- Advanced Options
- A1 Expand Filesystem: Just do it
- System Options
-
At this point, go ahead and reboot for the fun of it.
sudo reboot
- This will terminate your ssh connection
- After a few moments, connect again, but remember you will need to connect to the new hostname
ssh pi@<yourNewHostname.local>
- If you prefer, you can connect to your device via VNC if you set that up. Use the free VNC Viewer to do so by connecting to
<yourNewHostname>.local
and enteringpi
as the username, and the pasword you set
-
Let's do some upgrades!
$ sudo apt-get update $ sudo apt-get upgrade -y $ sudo apt install cmake wget p7zip -y
-
- Follow the Git Install instructions for setting up NVM
$ git clone https://github.com/nvm-sh/nvm.git ~/.nvm $ cd ~/.nvm $ git checkout v0.37.2 $ . ./nvm.sh
- Edit your bashrc with
nano ~/.bashrc
and enter the following AT THE TOP (required for non-interactive shells)
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
- Install the latest node with
nvm install node
- Upgrade npm with
npm i -g npm
-
Install pyenv and pyenv-virtualenv
- Follow the Basic Git checkout installation with some slight tweaks
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
- Edit your .bashrc
nano ~/.bashrc
and add the following AT THE TOP (required for non-interactive shells)
export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)"
- Install build dependencies:
$ sudo apt install libssl-dev libbz2-dev libreadline-dev libsqlite3-dev $ sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev -y
- Activate pyenv:
exec "$SHELL"
- List all available versions with:
pyenv install -l | grep 3.
- Install the version you want with, for example
pyenv install 3.9.1
- See documentation for optional build flags
- Install
pyenv-virtualenv
$ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
- Update your
bashrc
withnano ~/.bashrc
and add the following after your `"$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
- Restart your shell with
exec "$SHELL"
- Create a helper function for creating virtualenvs. Add the following to the bottom of your
bashrc
withnano ~/.bashrc
mkv() { DIR="${PWD##*/}" if [ $# -eq 1 ] then DIR="$1" fi pyenv virtualenv 3.9.1 $DIR echo $DIR > .python-version }
- Now, when you enter a new project, type
mkv
and it will use the folder name to create a new virtualenv with the python version you specified, or usemkv someName
to create the env with the namesomeName
. - From now on, when you enter this directory, the python environment will automatically source
- If you need to remove the venv in the future, type
pyenv virtualenv-delete someName
- After creating a new environment, it is a good idea to upgrade pip:
pip install --upgrade pip
-
Update your Git config (enter your name and email):
nano ~/.gitconfig
.[user] name = Robert Reed email = [email protected] [alias] br = branch st = status cm = commit ch = checkout fe = fetch pu = pull origin hardReset = reset --hard origin/master pom = push origin master po = push origin clear = git rm -r --cached .
-
If you are going to be developing a project with git, you will want to set up a deploy key to ease the process. For any projects you develop, take a look at this gist and follow the steps for "Set Up Deploy Key On Remote Server".
-
If you like, edit your bashrc with some other conveniences (at the bottom):
alias ls='ls -lFa' alias ma='git checkout main'
-
That's it! You should be pretty well sorted now to develop on your pi. Have fun!