Errors trying to run under Python3
I have changed the print statements to the new syntax. Getting other errors though. Is there a Python3 version of this software?
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\networkx\readwrite\edgelist.py", line 272, in parse_edgelist
edgedata = dict(literal_eval(edgedata_str.strip()))
TypeError: 'int' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 104, in <module>
main(args)
File "main.py", line 96, in main
nx_G = read_graph()
File "main.py", line 73, in read_graph
G = nx.read_edgelist(args.input, nodetype=int, create_using=nx.DiGraph())
File "<decorator-gen-650>", line 2, in read_edgelist
File "C:\Python36\lib\site-packages\networkx\utils\decorators.py", line 239, in _open_file
result = func_to_be_decorated(*new_args, **kwargs)
File "C:\Python36\lib\site-packages\networkx\readwrite\edgelist.py", line 379, in read_edgelist
data=data,
File "C:\Python36\lib\site-packages\networkx\readwrite\edgelist.py", line 276, in parse_edgelist
) from e
TypeError: Failed to convert edge data (['1']) to dictionary.
For anyone else having the same problem, I got this working on Python3/numpy 1.19.5/ gensim 3.8.3/networkx 2.5/node2vec 0.4.3. As follows:
Change print statements in word2vec.py to Python3 syntax (lines 46 and 48)
Change main.py line 71 from
G = nx.read_edgelist(args.input, nodetype=int, data=(('weight',float),), create_using=nx.DiGraph())
to
G = nx.read_weighted_edgelist(args.input, nodetype=int, create_using=nx.DiGraph())
In both word2vec.py and base_any2vec.py (both in Python36/Lib/site-packages/gensim/models) change
len(sentence)
to
len(list(sentence))
Change line 90 of main.py from
model.save_word2vec_format(args.output)
to
model.wv.save_word2vec_format(args.output)
this is helpful