Bigchaindb 2.2.2 error installing while building gevent - cython

Error compiling Cython file:
------------------------------------------------------------
...
cdef load_traceback
cdef Waiter
cdef wait
cdef iwait
cdef reraise
cpdef GEVENT_CONFIG
^
------------------------------------------------------------
src/gevent/_gevent_cgreenlet.pxd:181:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
Compiling src/gevent/greenlet.py because it changed.
I'm using ubuntu and getting this error while trying to install bigchaindb.
I'm following the tutorial at Bigchaindb docs and already using the latest version of pip

Related

unresolved external symbol asm in cython

Basically, I have a cython code where i want to call C's inline assembly. I tried below:
cdef extern from *:
"""
#include <stdio.h>
void print_endln(){
asm("nop");
}
"""
void print_endln()
print_endln()
But I get below error:
ids.obj : error LNK2001: unresolved external symbol asm
Location\iaa.cp39-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\link.exe' failed with exit code 1120
My OS is windows 10 x64, python version Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
I compile the code as python setup.py build_ext --inplace && python program.py
Is there something wrong I am doing?

DLDT (OpenVINO) install on Ubuntu 18.04 on Raspberry Pi 4 - Cython code error

I am trying to install the DLDT package on Ubuntu 18.04 running on the Raspberry Pi 4. The 2019 branch of DLDT seems to install correctly with some issues but can be rectified. However, the later version (i.e. 2020.3) is giving me the below error:
Error compiling Cython file:
------------------------------------------------------------
...
# Usage example:\n
# ```python
# ie = IECore()
# net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
# ```
cpdef IENetwork read_network(self, model: [str, bytes], weights: [str, bytes] = "", init_from_buffer: bool = "False"):
^
------------------------------------------------------------
/home/ubuntu/dldt/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pyx:136:10: Signature not compatible with previous declaration
Error compiling Cython file:
------------------------------------------------------------
...
cdef class LayersStatsMap(dict):
cdef C.IENetwork net_impl
cdef class IECore:
cdef C.IECore impl
cpdef IENetwork read_network(self, model : [str, bytes], weights : [str, bytes] = ?, bool init_from_buffer = ?)
^
------------------------------------------------------------
The CMAKE command I use is:
sudo cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_MKL_DNN=OFF -DENABLE_CLDNN=OFF -DENABLE_GNA=OFF -DENABLE_SSE42=OFF -DTHREADING=SEQ -DENABLE_OPENCV=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.6 -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython3.6m.so -DPYTHON_INCLUDE_DIR=/usr/include/python3.6 ..
It seems like there is an issue with the declaration of the function or the usage of it. Is there any advice on this from anybody?
Is this a compatibility issue? Is this related to some Cython version issues? The one I have is: 0.29.21
Would appreciate some help on this. Thanks in advance!
Well it turns out that I had two versions of cython on my RPi (i.e. 0.26 and 0.29) and the cmake was using the older version. Once I updated the cmake to use the 0.29 version everything was fine.
I also downloaded the latest version of DLDT (v 2020.4) and used the same cmake command as earlier. This version of DLDT checks for the minimum required Cython version which is 0.29 and this led me to the answer.
Another option to install and build openvino on Raspberry pi 4,
Download raspian installer 2019 version from https://download.01.org/opencv/2019/openvinotoolkit/R3/
Follow the step given in this link - https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_raspbian.html

Can't compile Cython function with multiple input arguments

I am trying to get Cython running and I think I'm almost there but have hit a snag that I do not understand. I can compile functions with a single argument, but not with multiple. I have this issue with python 3.3, but not 2.7.
I successfully compiled and ran "hello world" and fibonacci examples but when I try to compile anything with two or more input arguments I get an error when compiling.
To boil it down to a very simple case. This compiles, imports to python, and runs.
def cycheckadd(c):
b = 1
d = b + c
return d
This does not.
def cycheckadd(b,c):
d = b + c
return d
And returns the following error when building.
C:\Users\Chris\PycharmProjects\CythonTest>python setup.py build_ext --inplace
Compiling cycheck.pyx because it changed.
Cythonizing cycheck.pyx
running build_ext
building 'cycheck' extension
creating build
creating build\temp.win32-3.3
creating build\temp.win32-3.3\Release
c:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\WinPython-32bit-3.3.5.9\python-3.3.5\include -IC:\WinPython-32bit-3.3.5.9\python-3.3.5\include -c cycheck.c -o build\temp.win32-3.3\Release\
cycheck.o
writing build\temp.win32-3.3\Release\cycheck.def
creating build\lib.win32-3.3
c:\mingw\bin\gcc.exe -shared -s build\temp.win32-3.3\Release\cycheck.o build\temp.win32-3.3\Release\cycheck.def -LC:\WinPython-32bit-3.3.5.9\python-3.3.5\libs -LC:\WinPython-32bit-3
.3.5.9\python-3.3.5\PCbuild -lpython33 -lmsvcr100 -o build\lib.win32-3.3\cycheck.pyd
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmsvcrt.a(dupvs00137.o):(.idata$5+0x0): multiple definition of `_imp___assert'
C:\WinPython-32bit-3.3.5.9\python-3.3.5\libs/libmsvcr100.a(dqcgs00457.o):(.idata$5+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Compiled using the setup.py file below.
from setuptools import setup
from Cython.Build import cythonize
setup(
name = 'cython math check',
ext_modules = cythonize("cycheck.pyx"),
)
This result was generated using python 3.3 and cython 0.22. I do not have this problem when I use 2.7.
The compiler is MinGW. I have been using 32bit versions of Python on Windows 10-64bit. I have added the following config file to the python directory.
C:\WinPython-32bit-3.3.5.9\python-3.3.5\Lib\distutils\distutils.cfg
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
Any help would be greatly appreciated!
Thanks,
Chris

Reraising an exception in Cython on Python 2 and Python3

I have some Cython code that currently looks
exc = sys.exc_info()
raise exc[0], exc[1], exc[2]
This doesn't work on Python3, since the "raise from tuple" form is no longer allowed. Were this normal Python code, I would just use six.reraise, but that's not available to me here. What's the Cython friendly way to do the same, which works on both Python2 and Python3?
One great Cython feature is that the generated C code can be compiled for either Python 2 or Python 3. So your example above will work with either version of Python, unmodified.
You can tell Cython to compile code assuming Python 2 syntax and semantics (the -2 argument, which is on by default) or assuming Python 3 (the -3 argument). In either case, the resulting extension module source code can be compiled and used for Python 2 or Python 3, as long as the dynamic components (imports, etc.) are compatible.
For example:
def raises_exception():
raise KeyError("what you doin'?")
def foobar():
try:
raises_exception()
except Exception:
import sys
exc = sys.exc_info()
raise exc[0], exc[1], exc[2]
Here's a setup.py that will work on either Py2 or Py3:
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize("reraise.pyx"))
I can run python setup.py build_ext -i on either version of Python (provided I have cython installed for each), and the resulting extension module will work.
$ python setup.py build_ext -i # Py3 python
$ ipython3
Python 3.3.2 (v3.3.2:d047928ae3f6, Oct 4 2013, 15:49:17)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import reraise
In [2]: reraise.foobar()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-2-9e20eacfd84e> in <module>()
----> 1 reraise.foobar()
/.../reraise.so in reraise.foobar (reraise.c:916)()
/.../reraise.so in reraise.foobar (reraise.c:847)()
/.../reraise.so in reraise.raises_exception (reraise.c:762)()
KeyError: "what you doin'?"
In [3]:

Connecting MYSQL using C program in Eclipse

I am connecting the Mysql using c program in eclipse, I am using CYGWIN compiler to compile program. I have installed the mysql c connector and added the include files to the compiler and linker
but i am getting error
**** Build of configuration Debug for project DbConnectionC ****
make all
Building file: ../connection.c
Invoking: Cygwin C Compiler
gcc -I"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -include"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include\mysql.h" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"connection.d" -MT"connection.d" -o "connection.o" "../connection.c"
cygwin warning:
MS-DOS style path detected: D:\java\workspace\DbConnectionC\Debug
Preferred POSIX equivalent is: /cygdrive/d/java/workspace/DbConnectionC/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
../connection.c: In function `main':
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:57: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
../connection.c:61: warning: char format, different type arg (arg 2)
Finished building: ../connection.c
Building target: DbConnectionC.exe
Invoking: Cygwin C Linker
gcc -L"C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\lib\opt" -o "DbConnectionC.exe" ./connection.o -llibmysql.lib -lmysqlclient.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -llibmysql.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient.lib
collect2: ld returned 1 exit status
make: *** [DbConnectionC.exe] Error 1
makefile:29: recipe for target `DbConnectionC.exe' failed
**** Build Finished ****
Please help me on this
thanks in advance
In the first part you have some warnings about possible problems:
../connection.c:39: warning: implicit declaration of function `exit'
This means function exit() is not declared, your source needs an #include <stdlib.h>
../connection.c:46: warning: control reaches end of non-void function
You don't return a value at the end of main(), add a return 0; if the program succeeds.
In the second part are linker warnings:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -llibmysql.lib
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmysqlclient.lib
which means the linker needs a path to the libraries or the libraries do not exist or the library names are misspelled.
One possible solution is using -lmysql -lmysqlclient instead of -llibmysql.lib -lmysqlclient.lib, but I'm not that familiar with Windows.
Having said that, I suggest strongly, you look at https://stackoverflow.com/tags/c/info and look at some book links.