networkx ImportError: cannot import name 'graphviz_layout'

networkx ImportError: cannot import name ‘graphviz_layout’

先看

  1. https://github.com/CristiFati/Prebuilt-Binaries/blob/master/Windows/PyGraphviz/Readme.md
  2. https://blog.csdn.net/ty_0930/article/details/87438962
  3. https://networkx.github.io/documentation/networkx-1.9/examples/drawing/circular_tree.html
  4. https://stackoverflow.com/questions/33433274/anaconda-graphviz-cant-import-after-installation
  5. http://www.mamicode.com/info-detail-2422004.html

看完了都解决不了怎么办

# pip show networkx
Name: networkx
Version: 2.3
Summary: Python package for creating and manipulating graphs and networks
Home-page: http://networkx.github.io/
Author: Aric Hagberg
Author-email: hagberg@lanl.gov
License: BSD
Location: c:\python36\lib\site-packages
Requires: decorator
Required-by:

原来 graphviz_layout 在2.3中换成nx.nx_agraph.graphviz_layout

https://networkx.github.io/documentation/stable/tutorial.html#drawing-graphs

pos = nx.nx_agraph.graphviz_layout(G)

#%%
import networkx as nx
import matplotlib.pyplot as plt

# try:
#    from networkx import graphviz_layout
# except ImportError:
#     raise ImportError("This example needs Graphviz and either PyGraphviz or Pydot")

#%%
G=nx.balanced_tree(3,5)
#pos=nx.graphviz_layout(G,prog='twopi',args='')
pos = nx.nx_agraph.graphviz_layout(G,prog='twopi',args='')
plt.figure(figsize=(8,8))
nx.draw(G,pos,node_size=20,alpha=0.5,node_color="blue", with_labels=False)
plt.axis('equal')
#plt.savefig('circular_tree.png')
plt.show()

#%%

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值