B4A Library NinjaPython - Use Python Scripts in B4A

Michael Mejias

Member
Licensed User
Longtime User
Hello

Logger connected to: 192.168.209.101:5555
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
*** Service (starter) Create ***
** Service (starter) Start **
main_globals (java line: 417)
java.lang.ExceptionInInitializerError
at com.ninjadynamics.python.main._globals(main.java:417)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at com.ninjadynamics.python.main.initializeGlobals(main.java:317)
at com.ninjadynamics.python.main.afterFirstLayout(main.java:101)
at com.ninjadynamics.python.main.access$000(main.java:17)
at com.ninjadynamics.python.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1098]: Library '/system/lib/libhoudini.so' not found
at java.lang.Runtime.loadLibrary(Runtime.java:370)
at java.lang.System.loadLibrary(System.java:535)
at com.ninjadynamics.ninjapython.NinjaPython.<clinit>(NinjaPython.java:183)
... 17 more
 

walterf25

Expert
Licensed User
Longtime User
Awesome project, however i'm playing around with it and sending the following lines of code and i keep getting an error.

Any ideas why that is and how to get this to work, the reason i'm testing it with the argparse modile is because the scripts i have depend on the argparse module and was hoping i could port this project over to android.

the lines of code i'am sending are the following.

B4X:
Sub argpasrser As String
    Dim str As StringBuilder
    str.Initialize
    str.Append("import sys").Append(CRLF).Append("import argparse").Append(CRLF) _
    .Append("parser = argparse.ArgumentParser()").Append(CRLF) _
    .Append("parser.add_argument(" & """echo""" & ", help="&"""echo the string you use here"""&")").Append(CRLF) _
    .Append("args = parser.parse_args()").Append(CRLF)  _
    .Append("print args.echo")
    Log("command: " & str.ToString)
    Return str.ToString
End Sub

I'am calling this function which returns the formatted string to the
B4X:
Py.Execute(argpasrser)

but i keep getting the following error:


Thanks, i'm hoping i can find the solution to this so i can proceed and hopefully port this project and load it onto a raspberry pi running Android Things.

Regards,
Walter
 

AmirMK82

Member
Licensed User
hi,
thanks for this lib
ttps://www.b4x.com/android/forum/threads/ninjapython-use-python-scripts-in-b4a.85220/post-574574
how can I imoprt library with zip format?
 

Anurag Jain

Member
Licensed User
Hi, I have been trying this, but it appears that after execution, its not able to find python library, which it is trying to look in some folder. Do we need to install python in PC to run the code, ............
 
Hello, the idea from this project is really amazing !!!

I would like do some tests, please could you approve my request to download the lib.

tks a lot !!!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…