mozillazg / pypy

The unofficial GitHub mirror of PyPy (mirrored via https://github.com/mozillazg/job-mirror-hg-repos)
https://foss.heptapod.net/pypy/pypy
Other
443 stars 64 forks source link

Error Runing LightGBM "TypeError: expected c_char_p instance instead of int" #8

Open JinShng opened 2 years ago

JinShng commented 2 years ago

Use Linux(centos7), Runing LightGBM In Pypy3, An exception occurs when I run the following code

import joblib

lgb = joblib.load('./catigory_xh.pkl')

for k in lgb.feature_name():
    print(k);

Error Info

Traceback (most recent call last):
  File "/usr/local/src/pypy3.6/lib_pypy/_ctypes/basics.py", line 56, in from_param
    as_parameter = value._as_parameter_
AttributeError: 'int' object has no attribute '_as_parameter_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "model.py", line 5, in <module>
    for k in lgb.feature_name():
  File "/usr/local/src/pypy3.6/site-packages/lightgbm/basic.py", line 3655, in feature_name
    ptr_string_buffers = (ctypes.c_char_p * num_feature)(*map(ctypes.addressof, string_buffers))
  File "/usr/local/src/pypy3.6/lib_pypy/_ctypes/array.py", line 203, in __init__
    self[i] = arg
  File "/usr/local/src/pypy3.6/lib_pypy/_ctypes/array.py", line 229, in __setitem__
    cobj = self._type_.from_param(value)
  File "/usr/local/src/pypy3.6/lib_pypy/_ctypes/primitive.py", line 372, in from_param
    return super(SimpleType, self).from_param(value)
  File "/usr/local/src/pypy3.6/lib_pypy/_ctypes/basics.py", line 59, in from_param
    self.__name__, type(value).__name__))
TypeError: expected c_char_p instance instead of int

LightGBM version:

Name: lightgbm
Version: 3.3.1
Summary: LightGBM Python Package
Home-page: https://github.com/microsoft/LightGBM
Author: 
Author-email: 
License: The MIT License (Microsoft)
Location: /usr/local/src/pypy3.6/site-packages
Requires: numpy, scikit-learn, scipy, wheel
Required-by: 

Pypy Version:

Python 3.6.12 (db1e853f94de, Nov 18 2020, 09:49:19)
[PyPy 7.3.3 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]

In fact, I have tried in other versions, and the error is the same catigory_xh.pkl