Android Question Shell library for B4A

warayTek

Member
Licensed User
I'm looking for a shell library similar to jShell in B4J. My goal is to run scripts in python (python3 is installed). Thank you for your time.
 

warayTek

Member
Licensed User
I am trying to display the python version installed with the following script but cannot.
B4X:
Sub btnGetPythonVersion_Click
    ' Execute shell command to get the Python version
    Dim sb As StringBuilder
    sb.Initialize
    p.Shell("sh", Array As String("-c", "python3 --version || python --version"), sb, Null)
Dim pythonVersion As String = sb.ToString.Trim
    
    ' Display the result
    If pythonVersion = "" Then
        lblPythonVersion.Text = "Error: Unable to get Python version"
    Else
        lblPythonVersion.Text = "Python Version: " & pythonVersion
    End If
End Sub
I have python 3.11.4 installed
py.png
 
Upvote 0

teddybear

Well-Known Member
Licensed User
How do you install python3, it seems you installed it in Termux.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The python interpreter is integrated into the pydroid3 app, it is not a system command, so you can't access it via the shell.
 
Upvote 1
Top