nikhilkumarsingh / recursion-tree-plotter

A python decorator to generate a visual tree for recursive functions.
MIT License
13 stars 3 forks source link

Errors ! Help needed. I think, problems due to hardcoded paths. #2

Open aahnik opened 3 years ago

aahnik commented 3 years ago

I cloned the repo and then created a virtual environment and installed requirements.txt.

Now I moved into examples directory and tried running fib.py . Got this error.

Traceback (most recent call last):
  File "/home/aahnik/recursion-tree-plotter/examples/fib.py", line 15, in <module>
    fib(5)
  File "../recursion_tree_plotter.py", line 40, in wrapper
    display_recursion_tree()
  File "../recursion_tree_plotter.py", line 29, in display_recursion_tree
    recursion_tree.write_png(f"plots/{func.__name__}_{int(time.time())}.png")
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0_1/lib/python3.9/site-packages/pydot/__init__.py", line 1807, in <lambda>
    lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0_1/lib/python3.9/site-packages/pydot/__init__.py", line 1909, in write
    dot_fd.write(self.create(prog, format))
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0_1/lib/python3.9/site-packages/pydot/__init__.py", line 1950, in create
    raise InvocationException(
pydot.InvocationException: GraphViz's executables not found

I tried running

python examples/fib.py

I got this error:

Traceback (most recent call last):
  File "/home/aahnik/recursion-tree-plotter/examples/fib.py", line 4, in <module>
    from recursion_tree_plotter import plot_recursion_tree
ModuleNotFoundError: No module named 'recursion_tree_plotter'

I copied fib.py to the root directory of project and then ran python fib.py

Got this:

Traceback (most recent call last):
  File "/home/aahnik/recursion-tree-plotter/fib.py", line 15, in <module>
    fib(5)
  File "/home/aahnik/recursion-tree-plotter/recursion_tree_plotter.py", line 40, in wrapper
    display_recursion_tree()
  File "/home/aahnik/recursion-tree-plotter/recursion_tree_plotter.py", line 29, in display_recursion_tree
    recursion_tree.write_png(f"plots/{func.__name__}_{int(time.time())}.png")
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0_1/lib/python3.9/site-packages/pydot/__init__.py", line 1807, in <lambda>
    lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0_1/lib/python3.9/site-packages/pydot/__init__.py", line 1893, in write
    dot_fd = open(path, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'plots/fib_1607177610.png'

I think as Directory paths are hardcoded. So all issues are coming.

It would be great, if we packaged it and published to PyPI.

aahnik commented 3 years ago

In addition to above errors:

image