Error compiling Cython file

I got this error, whan running python setup.py install for pyrosm-0.6.0.

Compiling pyrosm/_arrays.pyx because it depends on /usr/lib/python3.8/site-packages/Cython/Includes/libc/string.pxd.
Compiling pyrosm/data_filter.pyx because it depends on /usr/lib/python3.8/site-packages/Cython/Includes/libc/string.pxd.
Compiling pyrosm/pbfreader.pyx because it depends on /usr/lib/python3.8/site-packages/Cython/Includes/libc/string.pxd.
[1/3] Cythonizing pyrosm/_arrays.pyx
[2/3] Cythonizing pyrosm/data_filter.pyx

Error compiling Cython file:


import numpy as np
from cykhash.khashsets cimport Int64Set_from_buffer
^

pyrosm/data_filter.pyx:2:0: ‘cykhash/khashsets.pxd’ not found

Error compiling Cython file:


import numpy as np
from cykhash.khashsets cimport Int64Set_from_buffer
^

pyrosm/data_filter.pyx:2:0: ‘cykhash/khashsets/Int64Set_from_buffer.pxd’ not found

Error compiling Cython file:

cdef filter_array_dict_by_indices_or_mask(array_dict, indices):
return {k: v[indices] for k, v in array_dict.items()}

cdef get_lookup_khash_for_int64(int64_id_array):
return Int64Set_from_buffer(
^

pyrosm/data_filter.pyx:186:11: ‘Int64Set_from_buffer’ is not a constant, variable or function identifier

Error compiling Cython file:


Creates a (boolean) mask for the given source array flagging True
all items that exist in the ‘osm_ids’ array. Can be used to filter items
e.g. from OSM node data arrays.
“”"
n = len(src_array)
lookup = Int64Set_from_buffer(osm_ids)
^

pyrosm/data_filter.pyx:215:13: ‘Int64Set_from_buffer’ is not a constant, variable or function identifier
Traceback (most recent call last):
File “setup.py”, line 79, in
ext_modules=cythonize(os.path.join(“pyrosm”, “*.pyx”),
File “/usr/lib/python3.8/site-packages/Cython/Build/Dependencies.py”, line 110
2, in cythonize
cythonize_one(*args)
File “/usr/lib/python3.8/site-packages/Cython/Build/Dependencies.py”, line 1225, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyrosm/data_filter.pyx
cykhash.khashsets is in the path “C:\cygwin64\tmp\pip-req-build-t6rr0n8h\src\cykhash”. I’m using Cygwin to build with Python3.8 on a Windows system.

I tried…

from cygdrive.c.tmp.pip-req-build-t6rr0n8h.src.cykhash.khashsets import Int64Set_from_buffer

…but got a Syntax error.

I tried moving the cykhash folder to the tmp folder to avoid the possibility that the dashes in the other folder name might be presenting a problrm, and used…

from cygdrive.c.tmp.cykhash.khashsets import Int64Set_from_buffer

… but got

No module named ‘cygdrive’

What can I do to resolve the problem?

This is simply an issue finding modules, and not specific to Cython. The errors tell you the files they can’t find. Without knowing the time structure of your projects, we can’t help much

You’re right that hyphens can’t be in package names. Also, in your later attempts, did you forget to cimport?

I got an error when using cimport.

  File "<stdin>", line 1
    from cykhash.khashsets cimport Int64Set_from_buffer
                           ^
SyntaxError: invalid syntax

So I used import.

time structure?
I just downloaded the pyrosm-0.6.0 from PYPI, extracted it; cd into root;

$ cd pyrosm-0.6.0

ran setup install.

$ python003 setup.py install

That’s it. I didn’t change the structure, and I think both Cygwin and Python has all the required dependencies.

Notice that pyrosm requires geopandas to work.
I have geopandas installed - geopandas 0.9.0

Edit
So I should try cimport? I’ll do that now.
error : SyntaxError: invalid syntax

May I ask why you are trying to build pyrosm from source? There’s likely an existing compiled distribution for your platform already, and can be installed with

pip install pyrosm

The problem you’re having is that you are missing some required build dependencies. These are found in the build-system.requires key of the pyproject.toml file. Using a package installer (eg pip) will handle all of this automatically. For example, instead of running python3 setup.py install, try running pip install .

I think pip install is standard procedure for python users. The reason I am building from source is because pip install failed.
Would you like to see the errors?

The problem you’re having is that you are missing some required build dependencies. These are found in the build-system.requires key of the pyproject.toml file.

Thank you.
Looking at that file reveals I am missing ‘cykhash’.
Never knew what that file was. That’s something new you taught me. Thanks. :wink:
It’s installing now, after I installed ‘cykhash’.

PS
Would be nice if Python outputted an error message recommending checking that file for any missing dependencies.