B4J Question Test PyBridge BETA#2 from Erel's the old project

Theera

Expert
Licensed User
Longtime User
Refer to this, I have restart a new PyBridge and copy Erel's the source code to new project as PyOcrNew.b4j file.
I found that python folder which is in sub object folder is not found ,and I always have to upgrade pip to be version 25.0.1.
After,I have edited some code and run app.I have error.

Server is listening on port: 53500
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
connected
starting PyBridge v0.50
watchdog set to 30 seconds
Connecting to port: 53500
Error occurred on line: 56 (B4XMainPage)
(b4xmainpage.B4XPage_Created) - Python Error (ModuleNotFoundError) - Method: module.import_module: No module named 'markDown2'

and I don't know that how to see the original python to bring for using.

P.S.
the link has still be problem
B4X:
'Open global Python shell - make sure to set the path under Tools - Configure Paths. Do not update the internal package.
'Ctrl + click to open global Python shell: ide://run?File=%B4J_PYTHON%\..\WinPython+Command+Prompt.exe

My python.exe is c:\python\python313 directoty
 

Attachments

  • PyOCRNew.zip
    5.6 KB · Views: 26
Last edited:

Theera

Expert
Licensed User
Longtime User
Hi again,
My openion is that We should put #Region PythonConnected i.e.

B4X:
#Region PythonConnected
    Py.Initialize(Me, "Py")
    'โปรแกรมจะมองหา Python.exe Local Python ก่อน ถ้าหาไม่เจอ จะไปหาที่ global Python ซึ่งได้กำหนดเส้นทางไดเรคทอรี่Tools-Configure Paths ก่อนหน้า
    Dim opt As PyOptions = Py.CreateOptions("Python/python/python.exe")
  
    'แต่กรณีไม่ได้กำหนดเส้นทางไดเรคทอรี่Tools-Configure Paths และ ไม่สามารถค้นหา Local Python เจอ เราต้องเขียนคำสั่งต่อไปนี้แทน
    'Dim opt As PyOptions = Py.CreateOptions(File.Combine("", "C:\Python\python313\python.exe")) '<--  ถ้าเราไม่ใช้คำสั่งนี้จะ Error เกิดขึ้น
    Py.Start(opt)
    Wait For Py_Connected (Success As Boolean)
    If Success = False Then
        LogError("Failed to start Python process.")
        Return
    End If
#End Region
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
try changing
B4X:
   Dim opt As PyOptions = Py.CreateOptions(File.Combine("", "C:\Python\python313\python.exe")) '<--  ถ้าเราไม่ใช้คำสั่งนี้จะ Error เกิดขึ้น

to (note back slashes changed to forward slashes)
B4X:
   Dim opt As PyOptions = Py.CreateOptions(File.Combine("", "C:/Python/python313/python.exe")) '<--  ถ้าเราไม่ใช้คำสั่งนี้จะ Error เกิดขึ้น
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
try changing
B4X:
   Dim opt As PyOptions = Py.CreateOptions(File.Combine("", "C:\Python\python313\python.exe")) '<--  ถ้าเราไม่ใช้คำสั่งนี้จะ Error เกิดขึ้น

to (note back slashes changed to forward slashes)
B4X:
   Dim opt As PyOptions = Py.CreateOptions(File.Combine("", "C:/Python/python313/python.exe")) '<--  ถ้าเราไม่ใช้คำสั่งนี้จะ Error เกิดขึ้น
That line that I told myself, if have not configured the path and the IDE still not find local python, I have to do the line which it always works., but the link when I click , IDE doesn't find the global which isn't work. I do't know to resolved it.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
You don't need to update. Ignore that message.

Have you configured the path to Python under Tools - Configure Paths?
I have just resolved my problem about the links , I must copy the python folder which has WinPython command Prompt.exe within sub the object for local python and copy the python folder which has WinPython command Prompt.exe at the same directory of Python313., But I have still problem about your example of PyOcr.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Have you configured the path to Python under Tools - Configure Paths?
I found installation of Python313, it never install WinPython command prompt.exe, I must copy the python folder myself later.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
These are my results the one is for local python and another is for global python
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    10.6 KB · Views: 26
  • Capture (3).PNG
    Capture (3).PNG
    10.6 KB · Views: 27
Upvote 0

Theera

Expert
Licensed User
Longtime User
This is my B4J_PyBridgeTemplate.zip as my understood.
 

Attachments

  • B4J_PyBridgeTemplate.zip
    3.1 KB · Views: 21
Upvote 0
Top