Python name 'os' is not defined even though it is explicitly imported

前端 未结 2 1983
花落未央
花落未央 2021-02-13 13:14

I have a module called imtools.py that contains the following function:

import os 

def get_imlist(path):
    return[os.path.join(path,f) for f in o         


        
2条回答
  •  醉话见心
    2021-02-13 13:29

    Same problem is with me I am also trying to follow the book of Programming Computer Vision with Python by Jan Erik Solem" [http://programmingcomputervision.com/]. I tried to explore on internet to see the problem but I did not find any valuable solution but I have solved this problem by my own effort.

    First you just need to place the 'imtools.py' into the parent folder of where your Python is installed like C:\Python so place the file into that destination and type the following command:

    from PIL import Image
    from numpy import *
    from imtools import *
    

    Instead of typing the code with imtools.get_imlist() you just to remove the imtools from the code like:

    get_imlist()
    

    This may solve your problem as I had found my solution by the same technique I used.

提交回复
热议问题