Python Forum
NameError: name 'd' is not defined - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: NameError: name 'd' is not defined (/thread-16330.html)



NameError: name 'd' is not defined - synthex - Feb-23-2019

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?


RE: NameError: name 'd' is not defined - buran - Feb-23-2019

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