From setting up Raspberry Pi to installing Python environment

From setting up Raspberry Pi to installing Python environment

Introduction

`Although it is an article on Mac environment, the procedure is the same for Windows environment. Please read and try the environment-dependent part. ``

Purpose

After reading this article to the end, you will be able to:

No. Overview keyword
1 OS installation Raspberry Pi OS
2 Wi-Fi stealth SSID setting
3 Fixed IP address setting
4 SSH connection
5 VNC connection
6 Python environment installation pyenv

Execution environment

environment Ver.
macOS Catalina 10.15.6
Raspberry Pi OS (Raspbian) 10
Raspberry Pi Imager 1.4
pyenv 1.2.20
Python 3.7.3

Related articles

1. OS installation

SD card confirmation (macOS)

command.sh


~% diskutil list

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
...

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
...

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.9 GB    disk2
   1:             Windows_FAT_32 boot                    268.4 MB   disk2s1
   2:                      Linux                         31.6 GB    disk2s2

SD card initialization (macOS)

command.sh


~% diskutil eraseDisk FAT32 RPI /dev/disk2

Raspberry Pi Imager installation (macOS)

command.sh


~% brew cask install raspberry-pi-imager

Installation

  1. Start Raspberry Pi Imager> OS image selection> SD card selection> WRITE

2. Wi-Fi stealth SSID setting

Password encryption

command.sh


~$ wpa_passphrase {ssid} {password}

network={
    ssid="{ssid}"
    #psk="{password}"
    psk={psk}
}

Wi-Fi settings

command.sh


~$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

command.sh


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP

+ network={
+     ssid="{ssid}"
+     scan_ssid=1
+     psk={psk}
+ }

command.sh


^O
^X

command.sh


~$ sudo reboot

3. Fixed IP address setting

Default gateway check (macOS)

command.sh


~% netstat -rn

Routing tables

Internet:
Destination        Gateway            Flags        Netif Expire
default            {default gateway}  UGSc         en0
...

DNS server check (macOS)

command.sh


~% cat /etc/resolv.conf

nameserver {primary dns}
nameserver {secondary dns}

IP address setting

command.sh


~$ sudo nano /etc/dhcpcd.conf

command.sh


# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

+ interface wlan0
+ static ip_address={ip address}/24
+ static routers={default gateway}
+ static domain_name_servers={primary dns}
+ static domain_search=

command.sh


^O
^X

command.sh


~$ sudo reboot

4. SSH connection

SSH enabled setting

command.sh


~$ sudo touch /boot/ssh

Delete SSH host key (macOS)

command.sh


~% ssh-keygen -R {ip address}
~% ssh-keygen -R raspberrypi.local

SSH connection (macOS)

command.sh


~% ssh pi@{ip address}

command.sh


~% ssh [email protected]

5. VNC connection

VNC installation

command.sh


~$ sudo apt-get update
~$ sudo apt-get upgrade
~$ sudo apt-get install tightvncserver

VNC startup

command.sh


~$ tightvncserver

VNC connection (macOS)

  1. Finder> Go> Connect to server
  2. vnc: // {ip address}: 5901 or vnc: //raspberrypi.local: 5901 Input> Connect

6. Python environment installation

Library installation

command.sh


~$ sudo apt update
~$ sudo apt upgrade
~$ sudo apt install -y git openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev libffi-dev

pyenv installation

command.sh


~$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
~$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
~$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
~$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
~$ source ~/.bash_profile

Python installation

command.sh


~$ pyenv install -l

command.sh


~$ pyenv install {version}

Python switching

command.sh


~$ pyenv global {version}

Recommended Posts

From setting up Raspberry Pi to installing Python environment
Output from Raspberry Pi to Line
[Raspberry Pi] Changed Python default to Python3
From setting up a Rust environment to running Hello World
From installing Ansible to building a Python environment in Vagrant's virtual environment
How to use Raspberry Pi pie camera Python
From Python environment construction to virtual environment construction with anaconda
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
From nothing on Ubuntu 18.04 to setting up a Deep Learning environment in Tensor
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python
How to set up a Python environment using pyenv
How to use the Raspberry Pi relay module Python
Steps from installing Python 3 to creating a Django app
Python development environment construction 2020 [From Python installation to poetry introduction]
Procedure to exe python file from Ubunts environment construction
Output to "7-segment LED" using python on Raspberry Pi 3!
Setting up Jupyter Lab in a Python 3.9 venv environment
Introduced python3-OpenCV3 to Raspberry Pi
Post from Python to Slack
Cheating from PHP to Python
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
I talked to Raspberry Pi
Introducing PyMySQL to raspberry pi3
Raspberry Pi + Python + OpenGL memo
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
raspberry pi 1 model b, python
Update Python for Raspberry Pi to 3.7 or later with pyenv
Summary from building Python 3.4. * From source to building a scientific computing environment
How to get temperature from switchBot thermo-hygrometer using raspberry Pi
Translate I2C device driver for Arduino to Python for Raspberry pi
Connect Raspberry Pi to Alibaba Cloud IoT Platform with Python
Raspberry Pi + python + IoT device, environment construction procedure to start image processing and machine learning
RPi / CentOS> python> Execution environment distinction> import os / print os.uname ()> Whether to include raspberry pi
Call Matlab from Python to optimize
Port FreeRTOS to Raspberry Pi 4B
Use vl53l0x with Raspberry Pi (python)
[Python] Hit Keras from TensorFlow and TensorFlow from c ++ to speed up execution
Use your Raspberry Pi to read your student ID number from your student ID card
Numba to speed up as Python
How to rebuild python environment from pyenv on Mac environment (El Capitan)
Create folders from '01' to '12' with python
Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-
Post from python to facebook timeline
[Lambda] [Python] Post to Twitter from Lambda!
From building a Python environment for inexperienced people to Hello world
[Introduction] From installing kibana to starting
I want to run the Python GUI when starting Raspberry Pi
Raspberry pi initial setting (for myself)
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
Connect to utf8mb4 database from python
Set up Python environment on CentOS
Python (from first time to execution)
Post images from Python to Tumblr
Vim + Python development environment setting memo
A memo when connecting bluetooth from a smartphone / PC to Raspberry Pi 4
Get US stock price from Python with Web API with Raspberry Pi