dgorissen / pycel

A library for compiling excel spreadsheets to python code & visualizing them as a graph
GNU General Public License v3.0
573 stars 152 forks source link

Running example file #36

Closed ntropy-esa closed 6 years ago

ntropy-esa commented 6 years ago

Hello, New user of python. I am trying to run the example given with pycel. I set up an environment with Python 2.7, install pycell, network, numpy, matplotlip dependencies. In a Jupyter notebook, when I run:

    print "Compiling..., starting from D1"
    sp = c.gen_graph('D1',sheet='Sheet1')

I get the error:


Compiling..., starting from D1
Seed D1 expanded into 1 cells
1 filtered seeds 
1 cells on the todo list
Handling  Sheet1!D1
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-bf6729dbb0ea> in <module>()
      1 print("Compiling..., starting from D1")
----> 2 sp = c.gen_graph('D1', sheet='Sheet1')

C:\[...]anaconda3\envs\pycel\lib\site-packages\pycel-0.0.1-py2.7.egg\pycel\excelcompiler.pyc in gen_graph(self, seed, sheet)
    639 
    640             # parse the formula into code
--> 641             pystr,ast = self.cell2code(c1)
    642 
    643             # set the code & compile it (will flag problems sooner rather than later)

C:\[...]\anaconda3\envs\pycel\lib\site-packages\pycel-0.0.1-py2.7.egg\pycel\excelcompiler.pyc in cell2code(self, cell)
    578         if cell.formula:
    579             e = shunting_yard(cell.formula or str(cell.value))
--> 580             ast,root = build_ast(e)
    581             code = root.emit(ast,context=Context(cell,self.excel))
    582         else:

C:\[...]anaconda3\envs\pycel\lib\site-packages\pycel-0.0.1-py2.7.egg\pycel\excelcompiler.pyc in build_ast(expression)
    540             #    G.add_edge(stack.pop(),n)
    541         else:
--> 542             G.add_node(n,{'pos':0})
    543 
    544         stack.append(n)

TypeError: add_node() takes exactly 2 arguments (3 given)

Sounds very basic, but I can't figure out what is wrong? Not correct version of networkx?

ntropy-esa commented 6 years ago

Basic indeed. Networkx <2.0, not equal. pip uninstall networkx pip install networkx==1.11