Dask 未安装 graphviz 依赖项

Dask not installing graphviz dependency

我尝试导入 dask.dot 时遇到错误,提示找不到 graphviz 安装。但是,同时安装了 graphviz 和 pygraphviz。

balter@exalab3:~$ conda install dask
Fetching package metadata ...........
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /home/.../miniconda3:
#
dask                      0.13.0                   py35_0    conda-forge
balter@exalab3:~$ python
Python 3.5.3 | packaged by conda-forge | (default, Jan 23 2017, 19:01:48)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dask.dot
Traceback (most recent call last):
  File "/home/.../miniconda3/lib/python3.5/site-packages/dask/utils.py", line 63, in import_required
    return import_module(mod_name)
  File "/home/.../miniconda3/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'graphviz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../miniconda3/lib/python3.5/site-packages/dask/dot.py", line 11, in <module>
    graphviz = import_required("graphviz", "Drawing dask graphs requires the "
  File "/home/.../miniconda3/lib/python3.5/site-packages/dask/utils.py", line 65, in import_required
    raise RuntimeError(error_msg)
RuntimeError: Drawing dask graphs requires the `graphviz` python library and the `graphviz` system library to be installed.
>>>
balter@exalab3:~$ conda install graphviz
Fetching package metadata ...........
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /home/.../miniconda3:
#
graphviz                  2.38.0                        4    bioconda

如何解决这个问题?

我建议避免使用 conda graphviz 包。请参阅此处的讨论:https://github.com/ContinuumIO/anaconda-issues/issues/485

改为使用系统安装程序(brew、apt-get 或下载 Windows 安装程序)安装 graphviz,并在安装系统库后通过 pip 安装 graphviz 包。

MRocklin 的回答中提到的 github 问题已更新。 我用以下几行修复了问题:

conda install -c conda-forge graphviz

conda install -c conda-forge python-graphviz

这条评论解释了这一点https://github.com/ContinuumIO/anaconda-issues/issues/485#issuecomment-279296254

conda 列表输出:

漂白剂 1.5.0 py35_0
散景 0.12.5 py35_0
bzip2 1.0.6 vc14_3 [vc14] 胸部 0.2.3 py35_0
点击 6.7 py35_0
cloudpickle 0.2.2 py35_0
colorama 0.3.9 py35_0 conda-forge 循环仪 0.10.0 py35_0
cython 0.25.2 py35_1 conda-forge 达斯克 0.14.1 py35_0
装饰器 4.0.11 py35_0
分布式 1.16.1 py35_0
入口点 0.2.2 py35_1
fastparquet 0.0.5 py35_1 conda-forge 自由打字 2.5.5 vc14_2 [vc14] graphviz 2.38.0 4康达锻造 h5py 2.7.0 np112py35_0
hdf5 1.8.15.1 vc14_4 [vc14] heapdict 1.0.0 py35_1
html5lib 0.999 py35_0
icu 57.1 vc14_0 [vc14] ipykernel 4.6.1 py35_0
ipython6.0.0py35_0
ipython_genutils 0.2.0 py35_0
ipywidgets 6.0.0 py35_0
jinja2 2.9.6 py35_0
jpeg 9b vc14_0 [vc14] jsonschema 2.6.0 py35_0
木星 1.0.0 py35_3
jupyter_client 5.0.1 py35_0
jupyter_console 5.1.0 py35_0
jupyter_core 4.3.0 py35_0
libpng 1.6.27 vc14_0 [vc14] libtiff 4.0.6 vc14_3 [vc14] llvmlite 0.17.0 py35_0
挂坠盒 0.2.0 py35_1
标记安全 0.23 py35_2
matplotlib 2.0.0 np112py35_0
失调 0.7.4 py35_0
mkl 2017.0.1 0
msgpack-python 0.4.8 py35_0
nbconvert 5.1.1 py35_0
nbformat 4.3.0 py35_0
笔记本 5.0.0 py35_0
numba 0.32.0 np112py35_0
numexpr 2.6.2 np112py35_0
麻木 1.12.1 py35_0
文件 0.44 py35_0
openssl 1.0.2k vc14_0 [vc14] pandas 0.19.2 np112py35_1
pandocfilters 1.4.1 py35_0
partd 0.3.7 py35_0
path.py10.3.1py35_0
泡菜共享 0.7.4 py35_0
枕头 4.1.0 py35_0
点 9.0.1 py35_1
ply 3.9 py35_0 康达锻造 prompt_toolkit 1.0.14 py35_0
psutil 5.2.2 py35_0
py 1.4.33 py35_0 conda-forge pygments 2.2.0 py35_0
pyparsing 2.1.4 py35_0
pyqt 5.6.0 py35_2
pytables 3.2.2 np112py35_4
pytest 3.0.7 py35_0 conda-forge python 3.5.3 0
python-dateutil 2.6.0 py35_0
python-graphviz 0.6 py35_1 conda-forge pytz 2017.2 py35_0
pyyaml 3.12 py35_0
pyzmq 16.0.2 py35_0
qt 5.6.2 vc14_3 [vc14] qtconsole 4.3.0 py35_0
请求 2.13.0 py35_0
scipy 0.19.0 np112py35_0
安装工具 27.2.0 py35_1
简单泛型 0.8.1 py35_1
饮 4.18 py35_0
六个 1.10.0 py35_0
排序集合 0.5.3 py35_0
排序容器 1.5.7 py35_0
tblib 1.3.2 py35_0
测试路径 0.3 py35_0
节俭 0.3.9 py35_0 conda-forge tk 8.5.18 vc14_0 [vc14] toolz 0.8.2 py35_0
龙卷风 4.4.2 py35_0
特征 4.3.2 py35_0
vs2015_runtime 14.0.25123 0
wcwidth 0.1.7 py35_0
车轮 0.29.0 py35_0
widgetsnbextension 2.0.0 py35_0
win_unicode_console0.5py35_0
zict 0.1.1 py35_0
zlib 1.2.8 vc14_3 [vc14]

Dask documentation 已针对 graphviz 安装问题进行了更新:

You must install both the graphviz system library (with tools like apt-get, yum, or brew) and the graphviz Python library. If you use Conda then you need to install python-graphviz, which will bring along the graphviz system library as a dependency.

如前所述,下面将安装 python 和系统 graphviz 库:

conda install -c anaconda python-graphviz

但是,至少有一次我必须显式安装 graphviz 库(除了使用上面的命令通过 conda 安装之外):

sudo apt install graphviz