Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AttributeError: module 'numpy' has no attribute 'int'

I tried to run my code in another computer, while it successfully compiled in the original environment, this error can outta nowhere:

File "c:\vision_hw\hw_3\cv2IP.py", line 91, in SECOND_ORDER_LOG
original = np.zeros((5,5),dtype=np.int) File "C:\Users\brian2lee\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy_init_.py",
line 284, in getattr
raise AttributeError("module {!r} has no attribute " AttributeError: module ‘numpy’ has no attribute ‘int’

I’ve tried reinstalled my numpy, it does not work. Down below is my code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

def SECOND_ORDER_LOG (self,img):
    original = np.zeros((5,5),dtype=np.int)
    original[2,2] = 1
    kernel = np.array([[ 0,  0, -1,  0,  0],
    [ 0, -1, -2, -1,  0],
    [-1, -2, 16, -2, -1],
    [ 0, -1, -2, -1,  0],
    [ 0,  0, -1,  0,  0]])
    result = original + 1 * kernel
    sharpened = cv2.filter2D(img, -1, result)
    return sharpened

>Solution :

numpy.int was deprecated in NumPy 1.20 and was removed in NumPy 1.24.

You can change it to numpy.int_, or just int.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading