module numpy has no attribute unit8

+1 vote

Hi Guys,

I am trying to run the below CNN code in my system, but it is showing me an error.

import sys
os sys.path.append(os.pardir) 
import numpy as np 
from dataset.mnist import load_mnist 
from PIL import Image 
def img_show (img) : 
  pil_img = Image.fromarray(np.unit8(img)) 
  pil_img.show() 
module 'numpy' has no attribute 'unit8'

How can I solve this error?

Jun 23, 2020 in Python by akhtar
• 38,230 points
15,024 views

1 answer to this question.

+1 vote

Hi@akhtar,

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.

import sys
os sys.path.append(os.pardir) 
import numpy as np 
from dataset.mnist import load_mnist 
from PIL import Image 
def img_show (img) : 
  pil_img = Image.fromarray(np.uint8(img)) 
  pil_img.show() 
answered Jun 23, 2020 by MD
• 95,440 points

Related Questions In Python

0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,560 points
8,938 views
0 votes
0 answers

'module' object has no attribute 'PortScanner'

I am trying to run nmap in ...READ MORE

Jan 30, 2019 in Python by Karan
1,218 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
6,507 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by MD 1,675 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by Gitika 2,522 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
13,041 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,660 points
4,351 views
0 votes
2 answers

module 'numpy' has no attribute 'unit8'

Hi@Ganesh, I think you are calling the wrong ...READ MORE

answered Sep 22, 2020 in Python by MD
• 95,440 points
2,537 views
0 votes
1 answer

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

Hi@akhtar, To avoid this error you can use ...READ MORE

answered Apr 20, 2020 in Python by MD
• 95,440 points
20,459 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP