Python Forum
NameError: name 'd' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'd' is not defined
#1
Here steps of my code

from skimage import io
import mxnet as mx

test='C:/Users/Admin/Desktop/test.lst'# folder where must be my test.lst
DataSet='C:/Users/Admin/Downloads/mypic/'

data_iter = mx.image.ImageIter(
batch_size=4,
data_shape=(3,816, 1232),
label_width=4,
path_imglist='C:/Users/Admin/Desktop/test.lst',
path_root='DataSet')


for data in data_iter:
    d = data.data[0]
    if some_condition_is_True:
        break



import numpy as nd
img =nd.transpose(d,(0,2,3,1))
after it, i get error
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'd' is not defined
What's wrong?
Reply
#2
this error is not produced by this code.
Check the actual code that you are running.

Also if some_condition_is_True: - some_condition_is_True is just a placeholder, you need to replace it with actual condition that will break you out of the loop
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm getting a NameError: ...not defined. vonArre 2 167 Mar-24-2024, 10:25 PM
Last Post: vonArre
  Getting NameError for a function that is defined JonWayn 2 1,056 Dec-11-2022, 01:53 PM
Last Post: JonWayn
Question Help with function - encryption - messages - NameError: name 'message' is not defined MrKnd94 4 2,776 Nov-11-2022, 09:03 PM
Last Post: deanhystad
  [split] NameError: name 'csvwriter' is not defined. Did you mean: 'writer'? cathy12 4 3,203 Sep-01-2022, 07:41 PM
Last Post: deanhystad
  NameError: name ‘app_ctrl’ is not defined 3lnyn0 0 1,457 Jul-04-2022, 08:08 PM
Last Post: 3lnyn0
  NameError: name 'hash_value_x_t' is not defined Anldra12 5 1,865 May-13-2022, 03:37 PM
Last Post: deanhystad
  NameError: name 'cross_validation' is not defined tmhsa 6 13,182 Jan-17-2022, 09:53 PM
Last Post: TropicalHeat
  NameError: name “x” is not defined ... even though x is defined campjaybellson 7 14,677 Oct-20-2021, 05:39 PM
Last Post: deanhystad
  NameError: name 'Particle' is not defined in Pygame drunkenneo 4 3,306 Aug-15-2021, 06:12 PM
Last Post: bowlofred
  NameError: name 'u1' is not defined (on parser code Python) Melcu54 1 2,845 Jul-26-2021, 04:36 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020