“RuntimeError: Make sure the Graphviz executables are on your system's path” after installing Graphviz 2.38

后端 未结 29 2245
感动是毒
感动是毒 2020-12-02 06:00

I downloaded Graphviz 2.38 MSI version and installed under folder C:\\Python34, then I run pip install Graphviz, everything went well.

29条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 06:10

    For Linux users who don't have root access and hence can't use sudo command as suggested in other answers...

    First, activate your conda virtual-environment (if you want to use one) by:

    source activate virtual-env-name
    

    Then install graphviz, even if you have already done it using pip:

    conda install graphviz
    

    then copy the result of the following command:

    whereis dot
    

    In my case, its output is:

    /home/nader/anaconda2/bin/dot
    

    and add it to your PATH variable. Just run the command below

    nano ~/.bashrc
    

    and add these lines to the end of the opened file:

    PATH="/home/username/anaconda2/bin/dot:$PATH"
    export PATH
    

    now press Ctrl+O and then Ctrl+X to save and exit.

    Problem should be solved by now.

    Pycharm users, please note: Pycharm does not always see the PATH variable the same as your terminal. This solution does not work for Pycharm, and maybe other IDEs. But you can fix this by adding this line of code:

    os.environ["PATH"] += os.pathsep + '/home/nader/anaconda2/bin'
    

    to your python program. Do not forget to

    import os
    

    first :)

    Edit: If you don't want to use conda, you can still install graphviz from here without any root permissions and add the bin folder to your PATH variable. I didn't test this.

提交回复
热议问题