I am beginner in Python. I am using set python libraries and I want to take the part of my code in .py module. Where should I write "import" of the set of libraries, in the module, or in main file? If I don't write it in the module, program doesn't work.
#mainfile.py import cv2 import faceResearch faceResearch.mn() #faceResearch.py import cv2 def mn(): image = cv2.imread("Smiling/3--1873301-Smiling woman looking at camera.jpg") cv2.imshow("im", image) cv2.waitKey(0) cv2.destroyAllWindows() so, in which file should I write "import cv2"? in mainfile? in file of the module? or in both?
mainfile.pyandfaceResearch.py? Both are technically modules, and if all you want to do is execute the code infaceResearch.pyyou should get rid ofmainfile.pyand runfaceResearch.pydirectly.