Attributeerror: module ‘numpy’ has no attribute ‘int’ [SOLVED]

The attributeerror: module ‘numpy’ has no attribute ‘int’ appears while you are using the NumPy library in your Python script.

In this article, we show you the different solutions to this error attributeerror: module numpy has no attribute int. Aside from that, we will discuss why this error occurs and how to fix it.

What is “attributeerror: module ‘numpy’ has no attribute ‘int'” error?

The error “attributeerror: module numpy’ has no attribute int” means that you are trying to access the “int” attribute of the numpy module, however the numpy does not have that attribute.

In addition to that, this error usually occurs when you have mistakenly tried to access a non-existent attribute of a module.

What are the causes of “attributeerror: module ‘numpy'” has no attribute ‘int’ error?

  • If you have misspelled the attribute name or used an incorrect attribute name for the numpy module.
  • If you are using an old version of numpy that does not support the “int” attribute. The “int” attribute was introduced in numpy version 1.13.0.
  • If there are other modules or packages in your Python environment with the same name as the numpy module, it is one of the reason that makes conflicts when you try to import or use numpy.
  • If your numpy installation has been corrupted or incomplete, it prevents you from accessing the “int” attribute or other numpy functions and attributes.

Furthermore, if you are using NumPy version 1.24.0, the “” attribute has been removed or deprecated, not just int() but also object() and float().

The table shows aliases that have been deprecated in NumPy, and it shows how you are going to handle the deprecated types:

Python typesNumPy scalar types for precision
numpy.intintnumpy.int_ (default), numpy.int64, or numpy.int32
numpy.floatfloatnumpy.float64numpy.float_numpy.double (equivalent)
numpy.complexcomplexnumpy.complex128numpy.complex_numpy.cdouble (equivalent)
numpy.longintnumpy.int_ (C long), numpy.longlong (largest integer type)

How to fix “attributeerror: module ‘numpy'” has no attribute ‘int’ error

Here are the effective solutions you may use for fixing the attribute error.

1. Replace

import numpy as np


This code above will result in an error because or have been deprecated. You can solve this error by replacing numpy int with int.

import numpy as np

result= int(100) 

Note: If ever you just need to use older aliases, you may need to downgrade your NumPy version to v1.23.5 or below. Just make sure that it won’t affect other modules in your Python script because it might not be compatible with that version.

2. Check your Python script

Check your Python script to make sure that you are using the correct attribute name for numpy. For instance, if you are trying to use the “int” attribute of numpy to convert an array to integers, use “numpy.astype(int)” instead.

3. Restart the Python interpreter

In some cases, restarting the Python interpreter can help fix errors. Just close your Python interpreter, reopen it, and try running your Python script again.

Related Articles for Python Errors


This article provides solutions for the attributeerror: module ‘numpy’ has no attribute ‘int’, which is a big help in solving the problem you are currently facing.

Thank you very much for reading to the end of this article. Just in case you have more questions or inquiries, feel free to comment, and you can also visit our website for additional information.

Leave a Comment