[FIXED] RuntimeError: module compiled against api version 0x10 but this version of numpy is 0xe

Do not miss this exclusive book on Binary Tree Problems. Get it now for free.

With this article, you will be able to understand the error message "RuntimeError: module compiled against api version 0x10 but this version of numpy is 0xe" and fix it using two tested methods.

Table of contents:

  1. Understanding the Error
  2. Fix 1: Upgrade Numpy
  3. Fix 2: Install specific version of Numpy

Understanding the Error

If your Python program is using Numpy, you may face a version mismatch error.

import numpy as np

Error:

RuntimeError: module compiled against api version 0x10
but this version of numpy is 0xe

There can be other variants of this error such as:

RuntimeError: module compiled against api version v1
but this version of numpy is v2

The main issue is the software or library which you are using was compiled on a system with a different version of Numpy compared to the Numpy version available on the current system.

This is because the C API of Numpy is not updated frequently and hence, the corresponding version of Numpy in Python API and C API is not a direct 1:1 mapping. So, the software or library using Numpy was compiled with the latest or older version of Numpy C API.

Following is the corresponding mapping of C API and Python API of Numpy:

C API Version Numpy Version
0x00000008 1.7.x
0x00000009 1.8.x
0x00000009 1.9.x
0x0000000a 1.10.x
0x0000000a 1.11.x
0x0000000a 1.12.x
0x0000000b 1.13.x
0x0000000c 1.14.x
0x0000000c 1.15.x
0x0000000d 1.16.x
0x0000000d 1.19.x
0x0000000e 1.20.x
0x0000000e 1.21.x
0x0000000f 1.22.x
0x00000010 1.23.x
0x00000010 1.24.x

So if the error is:

RuntimeError: module compiled against api version 0x10
but this version of numpy is 0xe

then, it means:

  • Version needed is 0x10 that is 1.23.x or 1.24.x.
  • Version available on the system is 0xe that is 1.21.x.

The fix is to install the correct version of Numpy on the system.

Fix 1: Upgrade Numpy

The first fix is to upgrade the version of Numpy to the latest version:

pip install numpy --upgrade

This works in general as the common issue is that the software was compiled using the latest version of Numpy but the system has an older version.

Fix 2: Install specific version of Numpy

If you need 0x00000010 version of Numpy, you need to install version 1.23 or 1.24. To do this, you can specify the version while installing with pip install.

The command is as follows:

pip install numpy==1.23.0 --force

With the fixes in this article at OpenGenus, the error must be fixed. Ideally, these dependencies should be captured in requirements.txt file of the Python project.

Sign up for FREE 3 months of Amazon Music. YOU MUST NOT MISS.