Python bridge - dll error

Posted By: Grat

Python bridge - dll error - 08/04/19 11:20

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 File
beta_sendK.txt  (60 downloads)
Posted By: Grat

Re: Python bridge - dll error - 08/04/19 12:42

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
Posted By: jcl

Re: Python bridge - dll error - 08/05/19 11:22

Debug your Python functions with the interpreter before calling them from Zorro. This way you can find syntax errors easier.
Posted By: Grat

Re: Python bridge - dll error - 08/05/19 15:16

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
Posted By: Grat

Re: Python bridge - dll error - 08/05/19 15:33

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.
Posted By: jcl

Re: Python bridge - dll error - 08/07/19 10:29

You could contact the zmq developers and ask for embedded Python support. Most libraries support it. Otherwise you must use Pythonw.
© 2024 lite-C Forums