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

Errors trying to run under Python3 #124

Open
networks1 opened this issue Jan 4, 2023 · 2 comments
Open

Errors trying to run under Python3 #124

networks1 opened this issue Jan 4, 2023 · 2 comments

Comments

@networks1
Copy link

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.
@networks1
Copy link
Author

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)

@vermadev54
Copy link

this is helpful

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

2 participants