简体   繁体   中英

Plot a graph in NetworkX

I try to plot a simple graph in networkx , but this error message appears:

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.

Either upgrade your numpy installation, find a version of matplotlib compiled against your version of numpy , or build matplotlib from the source.

The problem is with the API mismatch as stated in the error message. First of all use pip to uninstall 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. Then install it as normal software installer. Make sure it finds your version of python during the installation. This is it !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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