Importerror: numba needs numpy 1.21 or less

Being a developer, you may have come across Importerror: numba needs numpy 1.21 or less error at some point.

This error occurs when there is an incompatibility between the versions of Numba and NumPy installed on your system.

In this article, we will explain what Numba and NumPy are, the causes of the error, and provide solutions to help you resolve the issue.

Prior to that let’s understand first the key terms involved in this error.

What is Numba?


Numba is an open-source JIT (Just-In-Time) compiler that translates Python code to machine code for efficient execution.

Additionally, it is designed to accelerate the execution of numerical functions and arrays in Python code.

Further, it significantly improves the performance of scientific computing applications.

What is NumPy?


NumPy is a powerful Python library for scientific computing that provides support for large, multi-dimensional arrays and matrices.

Furthermore, a large collection of high-level mathematical functions to operate on these arrays.

Also, it is an essential library for scientific computing in Python and is widely used in various fields, including data analysis, machine learning, and image processing.

Now let’s see what causes this error to occur…

Causes of importerror: numba needs numpy 1.22 or less

The “ImportError: Numba needs NumPy 1.21 or less” error occurs when the version of NumPy installed on your system is newer than the version of NumPy supported by the version of Numba you are using.

To avoid this error, you should ensure that the versions of NumPy and Numba are compatible.

You can check for version compatibility by running the following commands in your Python console:

import numba
import numpy
print(numba.__version__)
print(numpy.__version__)

If the versions of NumPy and Numba are incompatible, you will need to update one of them to ensure compatibility.

In the next section are the possible solutions you can try to fix this error.

Solutions to numba needs numpy 1.21 or less

There are several solutions to the “ImportError: Numba needs NumPy 1.21 or less” error such as:

1. Downgrading NumPy

If you have a newer version of NumPy installed, you can downgrade it to a version that is compatible with your version of Numba.

To do this, you can run the following command:

pip install numpy==1.21

This will downgrade your version of NumPy to version 1.21, which is the maximum version supported by Numba.

2. Upgrading Numba

If you have an older version of Numba installed, you can upgrade it to a version that is compatible with your version of NumPy.

To do this, you can run the following command:

pip install --upgrade numba

This will upgrade your version of Numba to the latest version, which should be compatible with the latest version of NumPy.

3. Creating a virtual environment

If you have multiple Python projects that require different versions of NumPy and Numba, you can create a virtual environment for each project to ensure that the correct versions of these libraries are installed.

To do this, you can use the virtualenv or conda package managers to create isolated environments for your projects.

That’s all for the solutions, now we have here the tips so that you can avoid the error.

Tips to avoid Importerror: numba needs numpy 1.21 or less

Here are things you should keep in mind to avoid this importerror.

  • Upgrade Numba
  • Downgrade NumPy
  • Use a virtual environment
  • Check dependencies

FAQs

Can I have multiple versions of NumPy installed on my computer?


Yes, you can have multiple versions of NumPy installed on your computer.

However, you should ensure that the correct version is being used for each project to avoid compatibility issues.

How do I know which version of NumPy I have installed?


You can check the version of NumPy installed on your system by running the following command in your Python console:

import numpy
print(numpy.version)

Can I still use Numba without NumPy?


No, Numba requires NumPy to function properly.

NumPy provides the necessary data structures and mathematical functions for Numba to accelerate numerical computations.

Anyway here are some other fixed errors wherein you can refer to try when you might face these errors:

Conclusion

In conclusion, the “ImportError: Numba needs NumPy 1.21 or less” error can be a frustrating issue for users of the Numba library.

However, with the solutions provided in this article, you should be able to resolve the error and continue using Numba for efficient scientific computing in Python.

It is also important to note the significance of keeping your software up-to-date and ensuring version compatibility to avoid such errors in the future.

I think that’s all for this article. I hope it helped you fix the error.

Until next time! 😊

Frequently Asked Questions

What is Python ImportError and what causes it?

ImportError is raised when an import fails for any reason. The most specific subtype is ModuleNotFoundError (no such module). Plain ImportError typically means the module exists but a name inside it can’t be imported, e.g. ‘cannot import name X from Y’ (X was renamed, removed, or moved between versions of Y). Common with library version mismatches.

How do I fix ‘cannot import name X from Y’?

Three steps: (1) Check the library version: pip show Y. (2) Check the changelog of Y, X may have been renamed or removed in a recent release. (3) Either pin to an older Y version (pip install Y==1.x.y) or update your code to the new import path. Common 2025-2026 examples: Werkzeug url_decode removed, Pillow ANTIALIAS renamed to LANCZOS.

Why does the import work in REPL but fail in script?

Two reasons. (1) Different Python interpreter: REPL uses one Python, your script uses another. Run python –version both times. (2) Different working directory: REPL is started where you have access to local modules, script is run from a different cwd. Add the project path to sys.path or use python -m to run as a module.

How do I avoid circular import errors?

Circular imports happen when module A imports B and B imports A at the top level. Three fixes: (1) Move one import inside the function that uses it (lazy import). (2) Restructure code so A and B both import from a third module C. (3) Use TYPE_CHECKING for type-hint-only imports: if TYPE_CHECKING: from a import X.

Where can I find more ImportError fixes?

Browse the ImportError reference hub for 67+ specific fixes (Flask, Werkzeug, Django, ML library versions). For missing-module cases see ModuleNotFoundError. For Python setup help see Python Tutorial hub.

Glay Eliver

Programmer & Technical Writer at PIES IT Solution

Glay Eliver is a programmer and writer at PIES IT Solution, author of over 600 tutorials at itsourcecode.com. Specializes in JavaScript tutorials, Microsoft Office how-tos (Excel, Word, PowerPoint), and Python error debugging covering ImportError, TypeError, AttributeError, ModuleNotFoundError, and JavaScript ReferenceError. Authored several of the site’s highest-traffic Excel and MS Office reference articles.

Expertise: JavaScript · MS Excel · MS Word · MS PowerPoint · Python · Python ImportError · Python TypeError · Python AttributeError · ModuleNotFoundError · JavaScript ReferenceError · Pygame  · View all posts by Glay Eliver →