1

I was trying to install the python library from ubers H3 as a custom library for aws redshift by using this for the installation. I followed the process and created the following function:

create or replace function geo_to_h3 (lat float, lon float, h3_resolution int)
 returns varchar(60)
stable
as $$
   from h3 import h3
   return h3.geo_to_h3( lat , lon, h3_resolution)
$$ language plpythonu;

When executing it with:

select geo_to_h3(38.774467 , -9.115598, 9)

I receive the following error:

OSError: /rdsdbdata/user_lib/0/0/1334190.zip/h3/out/libh3.so.1: cannot open shared object file: Not a directory

Tried the same with installing h3cy on redshift and using it in the code but I get:

ImportError: No module named _h3

I also tested this with a simple library to validate the creation, and it works.Could be because h3 for python is just a binding to the core library in C. Any advice on how to get this running or is it not possible to install every type of python library on AWS Redshift?

saeed foroughi
  • 1,662
  • 1
  • 13
  • 25
flowoo
  • 367
  • 3
  • 13
  • This looks like an issue with Python building the shared library incorrectly. We've been trying to fix this with [a re-write of the Python wrapper in Cython](https://github.com/uber/h3-py/tree/cython). I'm not an expert on the current build, so I'm not sure how well I could debug it. The new Cython branch isn't yet available on PyPI, but you could try to build it manually with the instructions on that branch's readme. If you try that, let me know how it works! Ideally, we'll have these install issues ironed out when we release the Cython re-write. – AJ Friend Feb 03 '20 at 00:48

1 Answers1

1

Libraries imported into Redshift are currently required to be pure Python. Pre-compiled C/C++ extensions are not allowed.

Joe Harris
  • 13,671
  • 4
  • 47
  • 54