简体   繁体   English

在NetworkX中绘制图表

[英]Plot a graph in NetworkX

I try to plot a simple graph in networkx , but this error message appears: 我尝试在networkx绘制一个简单的图形,但会出现以下错误消息:

RuntimeError: module compiled against API version 6 but this version of numpy is 4

Traceback (most recent call last):
  File "D:\project\awk\gg.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "D:\programs\python\lib\site-packages\matplotlib\pyplot.py", line 26, in <module>
    from matplotlib.figure import Figure, figaspect
  File "D:\programs\python\lib\site-packages\matplotlib\figure.py", line 24, in <module>
    import matplotlib.artist as martist
  File "D:\programs\python\lib\site-packages\matplotlib\artist.py", line 7, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "D:\programs\python\lib\site-packages\matplotlib\transforms.py", line 35, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import

How do I solve this? 我该如何解决这个问题?

You downloaded a binary version of matplotlib linked/compiled against a newer version of numpy than you have installed. 您下载了一个二进制版本的matplotlib链接/编译的版本比您安装的numpy版本更新。

Either upgrade your numpy installation, find a version of matplotlib compiled against your version of numpy , or build matplotlib from the source. 升级您的numpy安装,找到针对您的numpy版本编译的matplotlib版本,或者从源代码构建matplotlib

The problem is with the API mismatch as stated in the error message. 问题在于错误消息中所述的API不匹配。 First of all use pip to uninstall numpy. 首先使用pip卸载numpy。

     pip uninstall numpy

Then get the latest binary installer for numpy and matplotlib from here selecting your version of python and windows 32 or 64 bit. 然后从这里获取numpy和matplotlib的最新二进制安装程序,选择你的python版本和windows 32或64位。 Then install it as normal software installer. 然后将其安装为普通软件安装程序。 Make sure it finds your version of python during the installation. 确保在安装过程中找到您的python版本。 This is it !! 就是这个 !!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM