1

If any ideas how to enable PyDev(eclipse) enables path or symbolic link to call foreign program(programs in /usr/local/bin/) in MacOS(/Linux), please tell me.


I want to use graphviz via pygraphviz on PyDev in eclipse. However, error message occurred such as "ValueError: Program dot not found in path." or "ValueError: No prog dot in path."

I guessed the below similar problems of which the cause may be IDE(e.g. PyDev) not to enable paths to call foreign command, for example, /usr/local/bin/dot.

The reason is I could perform graphviz on eclipse in below environment just as expected.

  • Sample code I want to perform

     import pygraphviz
     G=pygraphviz.AGraph()
     G.add_node('a')
     G.add_edge('b','c')
     G.layout()
     G.draw('sample01.png')
    
  • Successed cases

    • In terminal.app, the upper sample code could be perform just as expected. Off course, the python was same used in my eclipe.
    • The same eclipse which run in the upper terminal.app by command "open ~/Application/Eclipse.app" can be performed the upper sample code just as expected. Off course, in the terminal.app the upper code can be performed.
  • My environment.

    • MacBookPro MacOS(10.10:yosemite)
    • Eclipse Luna (Installed via homebrew-cask)
    • PyDev 4.0
    • Python 3.4 (installed by conda)
    • PyGraphviz 1.3rc2 (built source codes gotten from GitHub)
    • Graphviz 2.38.0 (Installed via homebrew)
  • Similar question

Community
  • 1
  • 1
user2058374
  • 69
  • 1
  • 1
  • 11

2 Answers2

0

When you run your program from the terminal it can find the graphviz tool because its location is included in the PATH environment variable. This environment variable is defined in your ~/.bash_profile, which is executed if you log in at the terminal. Eclipse doesn't use this file and therefore doesn't know the location of graphviz.

So your problems boils down to "how to set an environment variable OS-X". If you phrase it like this, Google will return a lot more results since many people have encountered the same issue. Unfortunately the solution depends on your version of OS-X so I cannot give you a short answer here. Besides, other people have written far better answers than I can. I think this one may be a good starting point.

Community
  • 1
  • 1
titusjan
  • 5,376
  • 2
  • 24
  • 43
0

I solved this problem with the below method which is based on your suggestion.

1. Answer Method

Add the system path of Python with the below code.

os.environ['PATH'] indicates an operator of the system path. The below code added a path /usr/local/bin where there is a symbolic link file to the graphviz cui program to a based path /usr/bin:/bin:/usr/sbin:/sbin:'

You can find out your system base path using the below code.

    import os
    os.environ['PATH']='/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'

    import os
    print(os.environ.get('PATH'))

2. Tried Method (this could not solve)

To add system path in /etc/path.d/

I added a file "Eclipse" where there described /usr/local/bin to /etc/path.d/. But this method did not solve the problem.

Deepend
  • 4,057
  • 17
  • 60
  • 101