0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry pi 上で作成した Python プログラムをダブルクリックで起動させる方法

Last updated at Posted at 2025-04-04

はじめに
Raspberry pi4 上で作成した Python プログラムを Windows の Exe File の様にダブルクリックで起動することを試みた。一般的には、Pyinstaller を使用するのだが 私が作成したプログラム(Test001.py)では、Raspberry pi が以下のエラーメッセージを出して実行出来なかった。

lib/arm-linux-gnueabihf/libc.so.6: version GLIBC_2.33' not found

原因は、単に glibc のバージョンが 2.33 以上ではないのであり glibcのバージョンを上げれば解決すると思う。

ちなみに glibc のバージョンを確認するには、以下の様にすれば良い。

$ ldd --version

私が使っている Raspberry pi4 では、以下の様に バージョン 2.31 と出た。

ldd (Debian GLIBC 2.31-13+rpt2+rpi1+deb11u11) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
作者 Roland McGrath および Ulrich Drepper。

glibc のバージョンを上げる方法は、検索すれば出て来るのであるが 調査する中で Python のプログラムを ダブルクリックするだけで 起動する方法が分かったので記載する。

尚、Rspberry pi のターミナル から手動で動作させるには 下記の様にする

$ python3 Test001.py

ここからが、本題!
Python プログラムを Windows の Exe File の様にダブルクリックで起動するには pythonのプログラムの先頭に
下記をおまじないとして記載すれば良いだけ!

#!/usr/bin/env python3

env は、Linux上で動き 定されたコマンドを実行するコマンドで Test001.py を python3 で実行させることを指示しているのでしょうね。きっと!

#!/usr/bin/env python3

ちなみに 先のおなじないだけでは実行時に 以下のメッセージが出て <実行> ボタンを押す必要がある。
png01.png

これを防ぐには、ファイルマネージャーを開き <編集>-<設定> を選びP002.png

□実行可能ファイルを立ち上げる時は選択肢を出さない(L)
にチェックを入れ<閉じる>
003.png


☆2025年04月 4日(金) 午後 0時30分 初版 (Ver1.00) 作成

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?