I am using PySpark 1.6.1. In my python program I'm using ctypes and trying
to load the liblept library via the liblept.so.4.0.2 file on my system.

While trying to load the library via cdll.LoadLibrary("liblept.so.4.0.2") I
get an error : 'builtin_function_or_method' object has no attribute
'__code__'

Here are my files

test.py

from ctypes import *

class FooBar:
        def __init__(self, options=None, **kwargs):
                if options is not None:
                        self.options = options

        def read_image_from_bytes(self, bytes):
                return "img"

        def text_from_image(self, img):
                self.leptonica = cdll.LoadLibrary("liblept.so.4.0.2")
                return "test from foobar"


spark.py

from pyspark import SparkContext
import test
import numpy as np
sc = SparkContext("local", "test")
foo = test.FooBar()

def file_bytes(rawdata):
        return np.asarray(bytearray(rawdata),dtype=np.uint8)

def do_some_with_bytes(bytes):
        return foo.do_something_on_image(foo.read_image_from_bytes(bytes))

images = sc.binaryFiles("/myimages/*.jpg")
image_to_text = lambda rawdata: do_some_with_bytes(file_bytes(rawdata))
print images.values().map(image_to_text).take(1) #this gives an error


What is the way to load this library?

Reply via email to