Skip to content

Instantly share code, notes, and snippets.

@pranav083
Created November 8, 2018 17:53
Show Gist options
  • Save pranav083/6ad4db8da1e569902825f7789e2e8cf4 to your computer and use it in GitHub Desktop.
Save pranav083/6ad4db8da1e569902825f7789e2e8cf4 to your computer and use it in GitHub Desktop.
How to fix AttributeError: module 'numpy' has no attribute 'unit8'
#######################################
###import function
import numpy as np
import cv2
#######################################
#######################################
###read the image
img =np.zeros((400,400),np.unit8)
#######################################
#######################################
###Do the processing
#############df##########################
#######################################
### show the image
cv2.imshow('image',img)
#######################################
#######################################
### close and exit
cv2.waitKey(0)
cv2.destroyAllWindows()
#######################################
error:
Traceback (most recent call last):
File "F:\Ubuntu_backup\eYRC#2683\Tutorials\Tutorials\2_exploring_the_image_matrix\3_makeChessboard\test_6.py", line 9, in <module>
img =np.zeros((400,400),np.unit8)
AttributeError: module 'numpy' has no attribute 'unit8'
[Finished in 0.4s]
@Narenderbeniwal
Copy link

You have used unit8 in your code. But NumPy has no attribute named unit8. You have to use uint8 instead of unit8 in your code. So make changes in your code and try once again. It will work.

@pranav083
Copy link
Author

Thanks for reply @Narenderbeniwal .

@OmniaOsman
Copy link

thanks, @Narenderbeniwal for help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment