2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RaspberryPi4の環境構築と設定

2
Posted at

はじめに

今回の環境構築に使用したものリスト

  • Raspberry Pi 4 Model B
  • 32 GBのMicro SDカード Toshiba 32GB
  • Micro SDカードが読み込み可能な接続器
  • キーボード
  • マウス
  • USB-Cと接続器 (最大5V/3A)
  • Micro HDMI
  • モニター

使用するOSはRaspberry Pi OS です。
自分はToshibaの使いましたが他のでも使える可能性があります。ただし相性の問題があるそうなのでご注意してください。
なお、Raspberry Pi用のモニターもありますが、自分はモニターがあったのでMicro HDMIで接続しました。

RaspberryPi設定の手順

  1. Raspberry Piの公式リンクから別のパソコンにRaspberry Pi Imagerをダウンロード
  2. Raspberry Pi ImagerからSDカードに書き込み、Raspberry Piに挿入
  3. Raspberry Piにキーボード、マウス、Micro HDMIを接続
  4. RaspberryPiにUSB-C接続。RaspberryPiはスイッチがないため、電源に接続した瞬間にスイッチONの状態になります
  5. 時間がかかりますが、デスクトップ画面が表示されれば完了

他の細かい設定

デフォルトPythonをPython3へ設定

RaspberryPiにはPython2が標準搭載されていますが自分の好みということもあってPython3をデフォルトに設定しました。
1.まずPython3をインストールします

$ sudo apt update
$ sudo apt install python3 idle3

2.つぎにTerminalを開いて下記のコマンドを入力してください。Python2とPython3のバージョンが確認できます。

$ python --version
Python 2.7.16
$ python3 --version
Python 3.7.3

3.python --versionと入力した際にPython2のバージョンが出てきたのが確認されました。今回はupdate-alterntivesというコマンドを使用しPythonのバージョンを選択することができるようにします。

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2

4.これでPythonの優先度を確認することができます

$ sudo update-alternatives --list python

5.最後にPythonのバージョンを変更します

$ sudo update-alternatives --config python

ライブラリのインストール

sodapy、pandas、matplotlibのライブラリがほしかったため、以下のコマンドを実行しました

$ pip install sodapy
$ pip install pandas
$ pip install matplotlib

補足情報ですが、Python2の状態でインストールするとPython3の状態で使用することができません。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?