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

ImportError: You must install pydot and graphviz for pydotprint to work. #25

Closed
bukosabino opened this issue Nov 27, 2017 · 16 comments
Closed

Comments

@bukosabino
Copy link

bukosabino commented Nov 27, 2017

When I run capsulenet.py, I have this error:

ImportError: Failed to import pydot. You must install pydot and graphviz for pydotprint to work.

But, I have installed pydot and graphviz:
pydot==1.2.3
graphviz==0.8.1

Any idea?

@XifengGuo
Copy link
Owner

try #7

@bukosabino
Copy link
Author

Solved. I commented the plot_model line.

Thanks you. Good code @XifengGuo

@nabsabraham
Copy link

hi @bukosabino, can you tell me what you commented out to get the plot_model to work?

@bukosabino
Copy link
Author

hi @BrownPanther ,

I think my reply doesn't make sense now because this line is out of current code.

@feng1919
Copy link

hi @bukosabino, can you tell me what you commented out to get the plot_model to work?

I got this to work by "brew install graphviz".

@ReneWu1117
Copy link

sudo apt-get install graphviz

@pcko1
Copy link

pcko1 commented Apr 10, 2019

pip install graphviz within my conda env solved it for me

p.s. I also tried conda install graphviz but problem persisted

@theccalderon
Copy link

hi @bukosabino, can you tell me what you commented out to get the plot_model to work?

I got this to work by "brew install graphviz".

This fixed it for me on my Mac.

@swun90
Copy link

swun90 commented Jul 27, 2019

Just in case someone using windows might need it, modify the pydot.py file.
It should be in <python_install_path>\Lib\Site-packages\pydot.py.
Besides pip install pydot and pip install graphviz, also install graphviz software. And add the software bin directory to the system's path.
And in class Dot(Graph), change self.prog = 'dot' to
self.prog = 'dot.exe'

Seems that the package was written for *nix system. So in windows, assign it to be an .exe file.

@emckenzi123
Copy link

I was able to get it to work with Tensorflow 2 on Ubuntu with:

pip install pydot
pip install pydotplus
apt-get install graphviz
pip install graphviz

@Rahma20
Copy link

Rahma20 commented May 6, 2020

@swun90 Thank you for your solution. It works for me :)

@pinxau1000
Copy link

Just in case someone using windows might need it, modify the pydot.py file.
It should be in <python_install_path>\Lib\Site-packages\pydot.py.
Besides pip install pydot and pip install graphviz, also install graphviz software. And add the software bin directory to the system's path.
And in class Dot(Graph), change self.prog = 'dot' to
self.prog = 'dot.exe'

Seems that the package was written for *nix system. So in windows, assign it to be an .exe file.

Also I needed to open CMD with administrator privileges and run dot -c or dot.exe -c.

@vganjali
Copy link

vganjali commented Feb 3, 2021

Install pydot, graphviz using conda/pip
Add a couple of changes in <python_install_path>\Lib\Site-packages\pydot.py as below:

def get_executable_extension():
    # type: () -> str
    if is_windows():
        #return '.bat' if is_anacoda() else '.exe'
        return '.exe'
    else:
        return ''

return.bat didn't exist in Graphviz install directory.

class Dot(Graph):
    """A container for handling a dot language file.

    This class implements methods to write and process
    a dot language file. It is a derived class of
    the base class 'Graph'.
    """



    def __init__(self, *argsl, **argsd):
        Graph.__init__(self, *argsl, **argsd)

        self.shape_files = list()
        self.formats = [
            'canon', 'cmap', 'cmapx',
            'cmapx_np', 'dia', 'dot',
            'fig', 'gd', 'gd2', 'gif',
            'hpgl', 'imap', 'imap_np', 'ismap',
            'jpe', 'jpeg', 'jpg', 'mif',
            'mp', 'pcl', 'pdf', 'pic', 'plain',
            'plain-ext', 'png', 'ps', 'ps2',
            'svg', 'svgz', 'vml', 'vmlz',
            'vrml', 'vtx', 'wbmp', 'xdot', 'xlib']

        #self.prog = 'dot' # Unix
        self.prog = r'C:\Program Files\Graphviz\bin\dot' # Windows absolute path

For some reason subprocess.Popen was not able to find 'dot.exe' from my system (I had Graphviz/bin to the system path variables), used absolute path instead and it worked!

@hkhdair
Copy link

hkhdair commented Mar 5, 2022

conda install graphviz

conda install graphviz solved the problem for me 👍

@ghost
Copy link

ghost commented May 21, 2022

conda install graphviz
solved the problem for me

@Abdelrhman2022
Copy link

Abdelrhman2022 commented May 31, 2022

The following commands solved the problem for me

pip install pydot
pip install pydotplus
pip install graphviz

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