You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Vibhatha Lakmal Abeykoon (Jira)" <ji...@apache.org> on 2020/04/30 03:23:00 UTC

[jira] [Created] (ARROW-8638) Arrow Cython API Usage Gives an error when calling CTable API Endpoints

Vibhatha Lakmal Abeykoon created ARROW-8638:
-----------------------------------------------

             Summary: Arrow Cython API Usage Gives an error when calling CTable API Endpoints
                 Key: ARROW-8638
                 URL: https://issues.apache.org/jira/browse/ARROW-8638
             Project: Apache Arrow
          Issue Type: Bug
          Components: C++, Python
    Affects Versions: 0.16.0
         Environment: Ubuntu 20.04 with Python 3.8.2
RHEL7 with Python 3.6.8
            Reporter: Vibhatha Lakmal Abeykoon
             Fix For: 0.16.0


I am working on using both Arrow C++ API and Cython API to support an application that I am developing. But here, I will add the issue I experienced when I am trying to follow the example, 

[https://arrow.apache.org/docs/python/extending.html]

I am testing on Ubuntu 20.04 LTS

Python version 3.8.2

These are the steps I followed.
 # Create Virtualenv

python3 -m venv ENVARROW

 

2. Activate ENV

source ENVARROW/bin/activate

 

3. pip3 install pyarrow==0.16.0 cython numpy

 

 4. Code block and Tools,

 

+*example.pyx*+

 

 
{code:java}

{code}
*from pyarrow.lib cimport *
def get_array_length(obj):
    # Just an example function accessing both the pyarrow Cython API
    # and the Arrow C++ API
    cdef shared_ptr[CArray] arr = pyarrow_unwrap_array(obj)
    if arr.get() == NULL:
        raise TypeError("not an array")
    return arr.get().length()def get_table_info(obj):
    cdef shared_ptr[CTable] table = pyarrow_unwrap_table(obj)
    if table.get() == NULL:
        raise TypeError("not an table")
    
    return table.get().num_columns()***

 

+*setup.py*+

 
{code:java}

{code}
*from distutils.core import setup
from Cython.Build import cythonizeimport os
import numpy as np
import pyarrow as pa
ext_modules = cythonize("example.pyx")for ext in ext_modules:
    # The Numpy C headers are currently required
    ext.include_dirs.append(np.get_include())
    ext.include_dirs.append(pa.get_include())
    ext.libraries.extend(pa.get_libraries())
    ext.library_dirs.extend(pa.get_library_dirs())*    
    *if os.name == 'posix':
        ext.extra_compile_args.append('-std=c++11')*    
    *# Try uncommenting the following line on Linux
    # if you get weird linker errors or runtime crashes
    #ext.define_macros.append(("_GLIBCXX_USE_CXX11_ABI", "0"))
setup(ext_modules=ext_modules)***

 

+*arrow_array.py*+

 
{code:java}

{code}
*import example
import pyarrow as pa
import numpy as np
arr = pa.array([1,2,3,4,5])
len = example.get_array_length(arr)
print("Array length {} ".format(len))***

 

+*arrow_table.py*+

 

 
{code:java}

{code}
*import example
import pyarrow as pa
import numpy as np
from pyarrow import csv*
*fn = 'data.csv'*
*table = csv.read_csv(fn)*
*print(table)*
*cols = example.get_table_info(table)*
*print(cols)***

 

+*data.csv*+
{code:java}
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
{code}
 

 

**When I try to run either of the python example scripts arrow_table.py or arrow_array.py, 

I get the following error. 

 
{code:java}
File "arrow_array.py", line 1, in <module>
 import example
ImportError: libarrow.so.16: cannot open shared object file: No such file or directory
{code}
 

 

*Note: I also checked this on RHEL7 with Python 3.6.8, I got a similar response.* 

 

 

 

 

 

 

+*Makefile*+

 

 
{code:java}

{code}
*install:*
         *python3 setup.py build_ext --inplace*
*clean:* 
         *rm -R *.so build *.cpp***

 

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)