1

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?

nilashan
  • 690
  • 1
  • 8
  • 30
  • 1
    Can you plot simple graphs, independently of networkx? – silvado May 31 '13 at 10:00
  • Can you import numpy? – TheMeaningfulEngineer May 31 '13 at 15:23
  • please edit the tags to point at the right version of windows. – tacaswell Jun 01 '13 at 02:33
  • 1
    How did you install NetworkX, and how did you install Numpy? Are you sure that you don't have Matplotlib already installed? – theta Jun 05 '13 at 06:49
  • I tried many ways. But I forgot it. But If you tell from start it would be easy for me. I want to draw some social network analysis graphs in networkx. Thats why I'm asking this question – nilashan Jun 05 '13 at 08:48
  • 2
    NetworkX isn't the tool for large maps such as social network dumps. And if don't understand your environment you won't go far, just by reusing code, not meant for beginners that aren't even familiar with Python. No need for rush, take it slowly – theta Jun 05 '13 at 10:02
  • how we plot independently in networkx – nilashan Jun 05 '13 at 17:53

2 Answers2

3

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.

tacaswell
  • 84,579
  • 22
  • 210
  • 199
1

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 !!

Santosh Ghimire
  • 3,087
  • 8
  • 35
  • 63