Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (monk12, Quad), 830 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Python bridge - dll error #477849
08/04/19 11:20
08/04/19 11:20
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

I trying the python bridge, but I cannot call the function in python script.

a) PythonTest.c is OK
Quote

PythonTest compiling........... ok

Python Version: 3.68
Returned: 0 10 20 30 40
Sum: 100


b) init for script - Ok
Code
  //-------- INT RUN -----------------------
    if (is(INITRUN)){
      #ifdef _0MQ
        if(!pyStart("../source/python/beta_sendK.py",1)) {
          printf("\nError - Python won't start!");
          return;
        }
      #endif        
    }


c) fce where I use
Code
//--------------------- 0MQ -> API -------------------------------------------------
  void sendTo(string cPom){
    #ifdef _0MQ
      string xSend=strf("Main('%s')",cPom);  
      printf("\n Test: %s",xSend );
      
      pyX(xSend);    
      int nRet=pyInt("retMsg");

      if (nRet==1)
        printf("\nNew predict send OK");
      else if (nRet==2)
        printf("\nNew predict is duplicate");
      else if (nRet==0)
        printf("\n0QM - undefined error");
      else 
        printf("\n0QM - no send - will never seing");
    
    #endif

  }


d) error from PyError
Quote

Traceback (most recent call last):
File "<string>", line 7, in <module>
File "e:\conda\lib\site-packages\zmq\__init__.py", line 42, in <module>
_load_libzmq()
File "e:\conda\lib\site-packages\zmq\__init__.py", line 9, in _load_libzmq
import sys, ctypes, platform, os
File "e:\conda\lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 nen� platn� aplikace typu Win32.
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'Main' is not defined
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function



source code python in att
( note: is not possible attach to script with extension .py )

maybe is a problem 64/32 bit installation of python, becouse manual say: Install Python 3.6.8 32 bit for Windows

Attached Files
beta_sendK.txt (60 downloads)
Last edited by Grat; 08/04/19 11:24.
Re: Python bridge - dll error [Re: Grat] #477850
08/04/19 12:42
08/04/19 12:42
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
After swith the 32-bit python.

Python script working OK.


But if I call it from Zorro is error again.
PyError.txt output
Quote

Traceback (most recent call last):
File "<string>", line 7, in <module>
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\select.py", line 35, in select_backend
reraise(ImportError, ImportError("Importing %s failed with %s" % (name, e)), exc_info[2])
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\utils\sixcerpt.py", line 33, in reraise
raise value.with_traceback(tb)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\cython\__init__.py", line 14, in <module>
__all__.extend(submod.__all__)
ImportError: Importing zmq.backend.cython failed with 'NoneType' object is not iterable
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'Main' is not defined
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function
SystemError: g:\a\3\s\objects\longobject.c:404: bad argument to internal function

Re: Python bridge - dll error [Re: Grat] #477853
08/05/19 11:22
08/05/19 11:22
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Debug your Python functions with the interpreter before calling them from Zorro. This way you can find syntax errors easier.

Re: Python bridge - dll error [Re: Grat] #477858
08/05/19 15:16
08/05/19 15:16
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
with python interpret working, but is a wrong if is call from zorro script. I thinking, python bridge cannot call zmq included in script. I go to exam laugh

Re: Python bridge - dll error [Re: Grat] #477860
08/05/19 15:33
08/05/19 15:33
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Ok,

is a problem with import zmq:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "e:\tmp\zorroS\python\lib\site-packages\pyzmq-18.0.2-py3.6-win32.egg\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process.

Code
function main()
{
	if(!pyStart("",1)) {
		printf("Error - Python won't start!");
		return;
	}
	
	pyX("import zmq; \nprint( zmq.zmq_version())");

...


is a possible use import in the bridge?

i thinking no,
from manual:

Alternatively to the Python bridge, Zorro can directly call the Python interpreter pythonw.exe and exchange data via file (see example). This method is slower, but works even when the used Python library does not support embedded Python.

Re: Python bridge - dll error [Re: Grat] #477865
08/07/19 10:29
08/07/19 10:29
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
You could contact the zmq developers and ask for embedded Python support. Most libraries support it. Otherwise you must use Pythonw.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1