2
10

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.

ラズパイでPython(CUI)のプログラムを自動で起動する

Posted at

ラズパイの自動起動のやり方はいくつか方法はある。
そのうちpythonのスクリプト(CUIもの)を自動で起動する方法の忘備録
pythonスクリプトは/home/pi/python.py
Raspbianのバージョンは8.0

CLI環境で行われるときは、/etc/rc.localで読み込みの最後に実行してしまうパターン

/etc/rc.local
python3 /home/pi/python.py

exit 0

GUI環境で行われるときは、autostartで実行してしまうパターン
1.次のフォルダに移動する
/etc/xdg/autostart (すべてのユーザの環境下で実行する場合)
$HOME/.config/autostart (特定のユーザの環境下で実行する場合)

2.次のファイルを作成し保存する

~/.config/autostart/python.desktop
[Desktop Entry]
Type=Application
Name=window
Exec=lxterminal -e "python3 /home/pi/python.py"

2
10
1

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
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?