0

I tested "Vectorized shapely operations using Cython" below site link.

https://jorisvandenbossche.github.io/blog/2017/03/18/vectorized-shapely-cython/

It works completely in jupyter-notebook, there is no error. but when I compiled it through setup.py and then import module in python scrpit, it happened importError like below

"ImportError /my_path/bla/bla/contains_cy.cpython-36m-x86_64-linux-gnu.so: undefined symbol: GEOSPreparedContains_r"

my setup.py file contents is as follows.

from disutils.core import setup
from disutils.extension import Extension
from Cython.Disutils import build_ext
from Cython.Build import cythonize

setup( ext_modules = cythonize('contains_cy.pyx') )

I compiled contains_py.pyx through setup.py file like this. There is no problem until contains_cy module is imported in python scrpit

python3 setup.py build_ext --inplace

When I imported contains_py module in python script, I met import Error like this

Python 3.6.8 (default, Aug 7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import contains_cy
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
ImportError: /my_path/bla/bla/contains_cy.cpython-36m-x86_64-linux-gnu.so: undefined symnol: GEOSPreparedContains_r

I am not sure what I am doing wrong. Thanks

Lim Yao
  • 3
  • 1
  • If you look at the link,(https://jorisvandenbossche.github.io/blog/2017/03/18/vectorized-shapely-cython/) it seems that other people have experienced the similar problem, but there is no answer. please help me – Lim Yao Apr 06 '20 at 23:24
  • If code have some problem, it cannot be executed in jupyter-notebook. but it works in jupyter-notebook completely. It seems like a problem with environmental variables... however I don't know what it is. – Lim Yao Apr 06 '20 at 23:29
  • 1
    I'm sure there's other duplicates too. You need add `libraries` to setup.py. In the Jupyter version this is taken care of by the arguments you pass to `%%cython`, but they don't exist here. – DavidW Apr 07 '20 at 07:03

0 Answers0