Open goodjs1 opened 5 years ago
Hi, the code is written under python 2.7, so probably you want to have another py2 environment to run it.
增加一行代码“ args = [arg.encode('utf-8') for arg in args]”就可以。
def init(self, args):
dir_path = os.path.dirname(os.path.realpath(file))
self.lib = ctypes.CDLL('%s/build/dll/libsetcover.so' % dir_path)
self.lib.Fit.restype = ctypes.c_double
self.lib.Test.restype = ctypes.c_double
self.lib.GetSol.restype = ctypes.c_double
# Convert args to byte strings
args = [arg.encode('utf-8') for arg in args]
arr = (ctypes.c_char_p * len(args))()
arr[:] = args
self.lib.Init(len(args), arr)
self.ngraph_train = 0
self.ngraph_test = 0
Hello, I ran the following code in s2v_mvc and got the error. Is it because the version of python? i am using python 3.5 How to fix it? Thanks.
graph_comb/code/s2v_mvc$ ./run_nstep_dqn.sh Traceback (most recent call last): File "main.py", line 78, in
api = MvcLib(sys.argv)
File "/graph_comb/code/s2v_mvc/mvc_lib/mvc_lib.py", line 18, in init
arr[:] = args
TypeError: bytes or integer address expected instead of str instance