ModuleNotFoundError: No module named config
config是个py文件,不能直接from
from config import QINIU_AVAILABLE, OSS_AVAILABLE, REDIS_URI, BASEDIR
下面举个类似例子:
resize_img.py代码
import globimport cv2import osimport timedef resize_img():dir_path = rD:\2439files = glob.glob(dir_path + "/*.png") + glob.glob(dir_path + "/*.jpg")index = 0for file in files:img = cv2.imread(file) # modify the image path to yoursif img.shape[1] != 160:x_scale = 160 / img.shape[1]index += 1img = cv2.resize(img, None, fx=x_scale, fy=x_scale, interpolation=cv2.INTER_AREA)cv2.imwrite(file[:-4] + ".jpg", img)print(len(files), index)if __name__ == \__main__