LoginSignup
0
0

More than 1 year has passed since last update.

androidスマホでpython開発環境構築

Last updated at Posted at 2022-11-16

今回はTermuxを利用してAndroidでPythonを活用する方法を紹介しよう。

1. Termuxのインストール方法

androidのPlayStoreからTermuxをインストールする。

andorid-termux.PNG

2. Python開発環境構築

  • Pythonをインストールしよう
    Termuxのアプリを開いて、以下のコマンドを実行します。
    pkg install python
    Screenshot_2022-11-16-23-21-13-83_84d3000e3f4017145260f7618db1d683.jpg

  • pythonコンソールでテストコード検証
    コマンドラインでpythonを入力し、Enterを押して、pythonコンソールを開く
    コンソールにprint("hello world")を入力、1Enterを押して、実行結果を確認する。
    Screenshot_2022-11-16-23-23-28-28_84d3000e3f4017145260f7618db1d683.jpg

  • pythonのソースコードファイル作成&実行

    • pyファイル作成のため、内部のストレージをアクセス必要です。まず【Termux】内部ストレージ・SDカードへアクセスの設定をします。
      コマンドラインにtermux-setup-storageを入力し、内部のストレージアクセスできるように設定する。
    $ cd ~storage                                  
    $ pwd                                      
    $ /data/data/com.termux/files/home/storage
    
    • pyファイル作成
    $ vim test.py
    vimで下記ソースコード入力し、test.pyで保存します。                   
    test_str = "hello world"
    print(test_str)
    
    • pyファイル実行
       python pyファイル名で実行します
    $ python test.py
    hello world 
    

以上です。androidスマホでpython開発環境の構築手順です。
ご参考出来れば嬉しいです。ありがとうございました。

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