Page 2 of 2
Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 12:47 pm
by Kwai chang caine
You have right, but in my case, it's just for use SELENIUM the remote webbrowser.
Unfortunately (for me and PB), the creator have create an OOP language
So obviously, all his library is OOP and then impossible to use with PB
The great SROD have create COMATE for the community, starting to Dishelper made in C
Before, i use COMATE for remote IE, and all it's done
But now, IE is not always updated on all machine, and sometime not accept all the last HTML, and mainly, IE is not portable
A friend show me PYTHON with SELENIUM for FF for replace COMATE and OLE for IE, and i must recognize that's works nearly also good than COM
It's the reason why, i'm forced to try to embeding PYTHON for use SELENIUM and FF all that in portable version.
For me, the dream is always everybody coding in C, but we know you and me it's not the case.
The C is always in the most used language, but all the new library, and other languages (C++, c#, JAVA, PYTHON, PHP, etc ..) is OOP, and i'm sad about that

Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:00 pm
by Kwai chang caine
I don't understand...i'm really a donkey

I have :
1/ Install Python 3.1.4
2/ Take the "Python31.dll"
3/ Uninstall Python
4/ Compile your code in console mode with "callpy.exe" with PB v4.51
5/ Put "callpy.exe" + python31.dll + first.py on root of C:
6/ Write "callpy first multiply 2 3" on the root in the cmd console
And i have this error with XP pro
C:\>callpy first multiply 2 3
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named encodings.utf_8
Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:13 pm
by infratec
Hi KCC,
copy callpy.exe first.py and the dll in one directory.
I compiled callpy.pb in ascii mode.
hmm....
Just tried it on my home PC: same result as you.
Strange I use the same OS (Win7 Pro X64) in the office: works like charme.
I'll have look...
Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:35 pm
by Kwai chang caine
Alleluia !!!!
I'm not alone to have this problem
You surely laugh but i have even thinking, with my little head to try to compile in UNICODE, without succes too, obviously
I'll have look...
You are an angel

Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:45 pm
by infratec
Some hints from the web means: a wrong PYTHONHOME environment variable
But I'd looked everyywhere (set, registry) there is nothing to find.
An other point is VC9 runtime environment.
The dll is compiled with vc9 and it needs the vc9 runtime environment.
it's in vc 2008 redist stuff.
Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:52 pm
by Kwai chang caine
Thanks a lot i take a look about this VC9
Me since the beginning i have the same error, even with the W7 of my office
With XP it's more understandable, but with W7....
Re: Embedding Python into your apps
Posted: Fri Jan 29, 2016 5:55 pm
by Kwai chang caine
It's strange, because i have two VC++ 2008 redistributable installed on my XP

And that works not two time better

Re: Embedding Python into your apps
Posted: Sat Jan 30, 2016 2:38 pm
by smacker
Got a question...
Is "python31.dll" the only version of the .dll this will work with?
Re: Embedding Python into your apps
Posted: Thu Nov 10, 2016 2:38 pm
by skinkairewalker
Hi everyone !
well , i have problems in import Python DLL ,
when i call with > OpenLibrary(1,"python35.dll")
dont call library ...
follow the screenshot >
http://prntscr.com/d5iquh
this is Dlls in my folder
http://prntscr.com/d5ipwg
how can i fix this ?
Re: Embedding Python into your apps
Posted: Thu Nov 10, 2016 5:24 pm
by jack
is the dll 32-bit or 64-bit?
my guess is that it's 32-bit and you need the 64-bit version since you are using PB x64, or you could use PB x86
Re: Embedding Python into your apps
Posted: Thu Nov 10, 2016 7:57 pm
by skinkairewalker
now show this error >
http://prntscr.com/d5n5j0
this is code used >
Code: Select all
Prototype Py_Initialize()
Prototype.s PyRun_SimpleString(String.s)
Prototype Py_Finalize()
If OpenConsole("Python with PB")
If OpenLibrary(0, "python35.dll")
PythonInitialize.Py_Initialize = GetFunction(0, "Py_Initialize")
PythonRunSimpleString.PyRun_SimpleString = GetFunction(0, "PyRun_SimpleString")
PythonFinalize.Py_Finalize = GetFunction(0, "Py_Finalize")
PythonInitialize()
pystring$ = "from time import time, ctime" + Chr(10)
pystring$ = "print('Hello PB World from Python!')" + Chr(10)
pystring$ + "print('Today is', ctime(time()))"
PythonRunSimpleString(pystring$)
PythonFinalize()
CloseLibrary(0)
Delay(3000)
EndIf
CloseConsole()
EndIf
Re: Embedding Python into your apps
Posted: Fri Nov 11, 2016 8:45 pm
by skinkairewalker
i fix this error !
just need Set System Variable ,
PYTHONHOME = C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX
AND
PYTHONPATH = C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX; C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX\DLLs;
C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX\Lib;
C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX\libs;
C:\Users\YOURPC\AppData\Local\Programs\Python\PythonXX\Lib\site-packages
and this bug has fixes ...
note > Python 3.2 or greater
Re: Embedding Python into your apps
Posted: Fri Jul 06, 2018 10:35 pm
by ccode
Hello!
I know that the thread is already old.
How does it work under a current Linux?
How can I use this to execute entire Python scripts?