Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"arr[:] = args" issue in main.py #30

Open
goodjs1 opened this issue Sep 1, 2019 · 2 comments
Open

"arr[:] = args" issue in main.py #30

goodjs1 opened this issue Sep 1, 2019 · 2 comments

Comments

@goodjs1
Copy link

goodjs1 commented Sep 1, 2019

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

@Hanjun-Dai
Copy link
Owner

Hi, the code is written under python 2.7, so probably you want to have another py2 environment to run it.

@YixuanLeeee
Copy link

增加一行代码“ 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants