Catalog
One 、 background
Two 、 Sudden inspiration —— The key to solving the problem
3、 ... and 、 Further growth
Four 、 Summary of knowledge points
I reported teacher tangandi's in Tencent class CV class , Then when practicing the credit card project , I want to test the previous code separately . as follows
from imutils import contours
import numpy as np
import argparse
import cv2
import myutils
# Set parameters
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="path to input image")
ap.add_argument("-t", "--template", required=True,
help="path to template OCR-A image")
args = vars(ap.parse_args())
When I “ Perform alone ” This string of code , Prompt error 【ModuleNotFoundError: No module named 'myutils'】, So I used pip Module installed myutils, Another error occurred during the execution 【the following arguments are required】, It means up there image and template Missing parameter . however , I am already in pycharm These two parameters have been added to the parameter editor of , Here's the picture .
So , I'll use it directly pycharm Of run Function to run the entire program file , It's completely normal again . I even unloaded that myutils After module , It's normal run. And I also found that there is a name under the peer folder of this program file myutils Of py file , It shows that executing a few strings of code alone will not call this file .
therefore , I guess pycharm Only through run When the function runs the program , Will be used configment Medium argument Parameters , Will call other... In the same folder py file .
and import function , You can not only import the officially released package library , The package library written by yourself and placed in the same level folder is also available .
therefore , Look at the functions of some strings of code alone , Module missing 、 Missing parameter , It is very likely that the above two cases . If there is no problem , You can also view a few strings of code separately , Better use it debug Function !!!
(1)pycharm Of run And executed separately ( Shortcut key shift+alt+e) The difference between
(2)import Which modules can be imported ? self-control 、 official 、 The third party .