amphibian-dev / toad

ESC Team's credit scorecard tools.
https://toad.readthedocs.io
MIT License
474 stars 173 forks source link

toad\c_utils.pyx:40:9: 'number' is not a type identifier Cython.Compiler.Errors.CompileError: toad/c_utils.pyx #118

Closed biubiu873 closed 1 year ago

biubiu873 commented 1 year ago

system version Windows 11 python version 3.11.0 Cython version 0.29.33 numpy version 1.24.2

I have tried updating numpy, cython versions。

I used python setup.py install to install the package downloaded from github, but cython showed a compilation error. I downloaded the c++ tool based on other people's experience, but the installation was still not successful。

Below is the error message:

D:\toad-0.1.1>python setup.py install
Compiling toad/c_utils.pyx because it changed.
Compiling toad/merge.pyx because it depends on C:\Users\yjwl1\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\__init__.pxd.
[1/2] Cythonizing toad/c_utils.pyx

Error compiling Cython file:
------------------------------------------------------------
...
cimport numpy as np
cimport cython

cdef number c_min(number[:] arr):
    ^
------------------------------------------------------------

toad\c_utils.pyx:9:5: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
cimport numpy as np
cimport cython

cdef number c_min(number[:] arr):
                 ^
------------------------------------------------------------

toad\c_utils.pyx:9:18: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        if res > arr[i]:
            res = arr[i]
    return res

cdef number c_sum(number[:,:] arr):
    ^
------------------------------------------------------------

toad\c_utils.pyx:18:5: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        if res > arr[i]:
            res = arr[i]
    return res

cdef number c_sum(number[:,:] arr):
                 ^
------------------------------------------------------------

toad\c_utils.pyx:18:18: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            res += arr[i, j]

    return res

cdef number[:] c_sum_axis_0(number[:,:] arr):
    ^
------------------------------------------------------------

toad\c_utils.pyx:29:5: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            res += arr[i, j]

    return res

cdef number[:] c_sum_axis_0(number[:,:] arr):
                           ^
------------------------------------------------------------

toad\c_utils.pyx:29:28: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            res[j] += arr[i, j]

    return res

cdef number[:] c_sum_axis_1(number[:,:] arr):
    ^
------------------------------------------------------------

toad\c_utils.pyx:39:5: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            res[j] += arr[i, j]

    return res

cdef number[:] c_sum_axis_1(number[:,:] arr):
                           ^
------------------------------------------------------------

toad\c_utils.pyx:39:28: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
cimport cython

cdef number c_min(number[:] arr):
    cdef number res = np.inf
        ^
------------------------------------------------------------

toad\c_utils.pyx:10:9: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            res = arr[i]
    return res

cdef number c_sum(number[:,:] arr):
    cdef number res = 0
        ^
------------------------------------------------------------

toad\c_utils.pyx:19:9: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    return res

cdef number[:] c_sum_axis_0(number[:,:] arr):
    cdef number[:] res = np.zeros(arr.shape[1], dtype=np.float)
        ^
------------------------------------------------------------

toad\c_utils.pyx:30:9: 'number' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    return res

cdef number[:] c_sum_axis_1(number[:,:] arr):
    cdef number[:] res = np.zeros(arr.shape[0], dtype=np.float)
        ^
------------------------------------------------------------

toad\c_utils.pyx:40:9: 'number' is not a type identifier
Traceback (most recent call last):
  File "D:\toad-0.1.1\setup.py", line 59, in <module>
    ext_modules = get_ext_modules(),
                  ^^^^^^^^^^^^^^^^^
  File "D:\toad-0.1.1\setup.py", line 27, in get_ext_modules
    return cythonize(extensions)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\yjwl1\AppData\Local\Programs\Python\Python311\Lib\site-packages\Cython\Build\Dependencies.py", line 1112, in cythonize
    cythonize_one(*args)
  File "C:\Users\yjwl1\AppData\Local\Programs\Python\Python311\Lib\site-packages\Cython\Build\Dependencies.py", line 1235, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: toad/c_utils.pyx
myelinji commented 1 year ago

same error when i install it

Secbone commented 1 year ago

@javakenny @myelinji Could you try to install from pip instead of from source code?

biubiu873 commented 1 year ago

@Secbone I first failed to install through the pip before installing using the source code, and they all reported the same error.

biubiu873 commented 1 year ago

@myelinji My version of python is 3.11, and currently cannot be installed through pip. need to wait for an official update;

However, currently, you can successfully install through the source code. If you encounter an error: Microsoft Visual C++14.0 or greater is required. You can follow the prompts to download https://visualstudio.microsoft.com/visual-cpp-build-tools/ And install python components and C++desktop development components.

2813f2a35be9b35fbcea49774c9257b

@Secbone (づ ̄ 3 ̄)づ