victorlei / smop

Small Matlab to Python compiler
MIT License
1.08k stars 409 forks source link

'DiGraph' object has no attribute 'node' #165

Open theRealSuperMario opened 4 years ago

theRealSuperMario commented 4 years ago

Hi,

I love the idea of this project, however, it does not work for me. See output below.

Is there anything I can do to help fix this?

WARNING: Token 'CLASSDEF' defined, but not used WARNING: Token 'END_UNEXPECTED' defined, but not used WARNING: There are 2 unused tokens Generating LALR tables /Users/sandrobraun/.local/lib/python3.7/site-packages/ply-3.11-py3.7.egg/ply/lex.py:760: FutureWarning: Possible nested set at position 65 c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags) /Users/sandrobraun/.local/lib/python3.7/site-packages/ply-3.11-py3.7.egg/ply/lex.py:498: FutureWarning: Possible nested set at position 118 lexre = re.compile(regex, reflags) str Traceback (most recent call last): File "/Users/sandrobraun/miniconda3/envs/multnano/lib/python3.7/site-packages/smop/main.py", line 66, in main G = resolve.resolve(stmt_list) File "/Users/sandrobraun/miniconda3/envs/multnano/lib/python3.7/site-packages/smop/resolve.py", line 54, in resolve u = G.node[n]["ident"] AttributeError: 'DiGraph' object has no attribute 'node' Errors: 1


pip freeze attrs==19.3.0 certifi==2020.6.20 decorator==4.4.2 importlib-metadata==1.7.0 iniconfig==1.0.0 more-itertools==8.4.0 networkx==2.4 numpy==1.19.1 packaging==20.4 pluggy==0.13.1 ply==3.11 py==1.9.0 pyparsing==3.0.0a2 pytest==6.0.0rc1 scipy==1.5.1 six==1.15.0 smop==0.41 toml==0.10.1 zipp==3.1.0

Python 3.7.7

Dozi7 commented 4 years ago

pip install networkx==1.11

RobBW commented 4 years ago

In python 3 it is. Nodes not node I think. Read back over the issues, it is not a new problem.

On Thu, 30 Jul 2020 at 08:18, Dozi7 notifications@github.com wrote:

pip install networkx==1.11

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/victorlei/smop/issues/165#issuecomment-665904044, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRNQJUPAF4H6FEVO7HNVTTR6B7XVANCNFSM4PEPOLRQ .

alexpazolinid commented 4 years ago

I am having a similar problem... c:\users\alexandre\anaconda3\lib\site-packages\ply\lex.py:760: FutureWarning: Possible nested set at position 65 c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags) c:\users\alexandre\anaconda3\lib\site-packages\ply\lex.py:498: FutureWarning: Possible nested set at position 118 lexre = re.compile(regex, reflags) str Traceback (most recent call last): File "c:\users\alexandre\anaconda3\lib\site-packages\smop\main.py", line 66, in main G = resolve.resolve(stmt_list) File "c:\users\alexandre\anaconda3\lib\site-packages\smop\resolve.py", line 54, in resolve u = G.node[n]["ident"] AttributeError: 'DiGraph' object has no attribute 'node' Errors: 1

IsabellLehmann commented 3 years ago

@alexpazolinid @theRealSuperMario did you try pip install networkx==1.11 as mentioned by @RobBW ? For me this worked. If it worked for you too, please close the issue. :)

DQuanR2 commented 3 years ago

It also got fixed for me with the "pip install networkx==1.11"

ipesanz commented 3 years ago

It worked for me in Windows 10, Python3.8 with network install After that.... the output is a long list of str and a file generated :)

TheShy321 commented 3 years ago

pip install networkx==1.11

thank you, For me this worked, it solve my problem

clobob commented 2 years ago

pip install networkx==1.11 it not worked for me. New error appears after change to networkx 1.11. File "D:\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python\Python39\Scripts\smop.exe\__main__.py", line 4, in <module> File "D:\Python\Python39\lib\site-packages\smop\main.py", line 17, in <module> from . import resolve File "D:\Python\Python39\lib\site-packages\smop\resolve.py", line 22, in <module> import networkx as nx File "D:\Python\Python39\lib\site-packages\networkx\__init__.py", line 84, in <module> import networkx.generators File "D:\Python\Python39\lib\site-packages\networkx\generators\__init__.py", line 5, in <module> from networkx.generators.classic import * File "D:\Python\Python39\lib\site-packages\networkx\generators\classic.py", line 21, in <module> from networkx.algorithms.bipartite.generators import complete_bipartite_graph File "D:\Python\Python39\lib\site-packages\networkx\algorithms\__init__.py", line 12, in <module> from networkx.algorithms.dag import * File "D:\Python\Python39\lib\site-packages\networkx\algorithms\dag.py", line 2, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (D:\Python\Python39\lib\fractions.py)

Python 3.9.7

DeeMW commented 2 years ago

pip install networkx==1.11 it not worked for me. New error appears after change to networkx 1.11. File "D:\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python\Python39\Scripts\smop.exe\__main__.py", line 4, in <module> File "D:\Python\Python39\lib\site-packages\smop\main.py", line 17, in <module> from . import resolve File "D:\Python\Python39\lib\site-packages\smop\resolve.py", line 22, in <module> import networkx as nx File "D:\Python\Python39\lib\site-packages\networkx\__init__.py", line 84, in <module> import networkx.generators File "D:\Python\Python39\lib\site-packages\networkx\generators\__init__.py", line 5, in <module> from networkx.generators.classic import * File "D:\Python\Python39\lib\site-packages\networkx\generators\classic.py", line 21, in <module> from networkx.algorithms.bipartite.generators import complete_bipartite_graph File "D:\Python\Python39\lib\site-packages\networkx\algorithms\__init__.py", line 12, in <module> from networkx.algorithms.dag import * File "D:\Python\Python39\lib\site-packages\networkx\algorithms\dag.py", line 2, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (D:\Python\Python39\lib\fractions.py)

Python 3.9.7

I would suggest just go to that source file (D:\Python\Python39\lib\site-packages\networkx\algorithms\dag.py), remove the import statement, and replace the gcd occurrences with math.gcd

DeeMW commented 2 years ago

the fractions.py is actually using math.gcd itself.

sarimmehdi commented 2 years ago

Why doesn't this work with the latest networkx? (2.6.2)

GBR-613 commented 2 years ago

Not sure what happens, but 'DiGraph' object has no attribute 'node' in networkx==1.11 as well:

(nx) c:\Users\GBR-6\nx\Scripts>pip install networkx==1.11
Collecting networkx==1.11
  Downloading networkx-1.11-py2.py3-none-any.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 731 kB/s
Collecting decorator>=3.4.0
  Using cached decorator-5.1.0-py3-none-any.whl (9.1 kB)
Installing collected packages: decorator, networkx
Successfully installed decorator-5.1.0 networkx-1.11

(nx) c:\Users\GBR-6\nx\Scripts>python
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import networkx as nx
>>> nx
<module 'networkx' from 'c:\\Users\\GBR-6\\nx\\lib\\site-packages\\networkx\\__init__.py'>
>>> nx.DiGraph
<class 'networkx.classes.digraph.DiGraph'>
>>> nx.DiGraph.node
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'DiGraph' has no attribute 'node'
>>> nx.DiGraph.nodes
<function Graph.nodes at 0x0000021694471318>
>>>

I am going to submit a PR.

GBR-613 commented 2 years ago

@victorlei PR submitted: https://github.com/victorlei/smop/pull/177 Please have a look.

seb5433 commented 1 year ago

I'm having the same issue with python 3.8 and networkx==1.11 has solved the problem.

Parikshit-Vyas commented 1 year ago

pip install networkx==1.11 it not worked for me. New error appears after change to networkx 1.11. File "D:\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python\Python39\Scripts\smop.exe\__main__.py", line 4, in <module> File "D:\Python\Python39\lib\site-packages\smop\main.py", line 17, in <module> from . import resolve File "D:\Python\Python39\lib\site-packages\smop\resolve.py", line 22, in <module> import networkx as nx File "D:\Python\Python39\lib\site-packages\networkx\__init__.py", line 84, in <module> import networkx.generators File "D:\Python\Python39\lib\site-packages\networkx\generators\__init__.py", line 5, in <module> from networkx.generators.classic import * File "D:\Python\Python39\lib\site-packages\networkx\generators\classic.py", line 21, in <module> from networkx.algorithms.bipartite.generators import complete_bipartite_graph File "D:\Python\Python39\lib\site-packages\networkx\algorithms\__init__.py", line 12, in <module> from networkx.algorithms.dag import * File "D:\Python\Python39\lib\site-packages\networkx\algorithms\dag.py", line 2, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (D:\Python\Python39\lib\fractions.py) Python 3.9.7

I would suggest just go to that source file (D:\Python\Python39\lib\site-packages\networkx\algorithms\dag.py), remove the import statement, and replace the gcd occurrences with math.gcd

Thanks a lot ! <3