Graphviz's executables are not found (Python 3.4)

后端 未结 26 1382
故里飘歌
故里飘歌 2020-11-29 05:00

I am running Python3.4 on Windows 7. I am trying to use the Python interface for graphviz. This is a script I intend to run:

from graphviz import Digraph
imp         


        
26条回答
  •  失恋的感觉
    2020-11-29 05:52

    Please note that I am using windows 10. some of the following may or may not applicable for other versions of windows or operating systems:

    ** Note 2: **
    "the Graphviz bin file address on your system" can be C:\Program Files (x86)\Graphviz2.38\bin or any other path you installed Graphviz there.

    We have problem not only with Graphviz but also with other external EXE files we want to use in Jupyter.
    The reason is when jupyter wants to import a package it looks in working directory to find it and when it fails to find the package it returns such errors.
    What we can do is tackle this is as follows:
    1) check if the Graphviz is installed on your system and if not you can download and install it from:

    https://graphviz.gitlab.io/_pages/Download/Download_windows.html
    and then install it. When you installing Graphviz, keep in mind where (in which folder) you are installing it. If you see the above error when you use

    import graphviz
    

    then you have several options:

    2) you can call the .exe file in the ipynb via

    import os
    os.environ["PATH"] += os.pathsep + r'the Graphviz bin file address on your system'
    

    It is my experience that it is only works for the same ipynb that I am working with and every time that I open the notebook I need to call this lines of code.

    3) If you want the Jupyter where to find the exe file, you need to set environmenal path.
    In windows 10 you can do this going to:
    Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit > New
    and then add the "the Graphviz bin file address on your system" In windows 8 or lower go to :
    Control Panel > System and Security > System > Advanced System Settings > Environment Variables
    and then add the ;(semicolon) + "the Graphviz bin file address on your system" to the end of path string
    Note: remember to restart your machine.

    4) and even this does not work, define a variable going to:
    Control Panel > System and Security > System > Advanced System Settings > Environment Variables and then:

    Then define a variable as this:

    Remember to name the variable Graphviz. At last restart your PC and hope it works.

提交回复
热议问题