程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python error: the following arguments are required

編輯:Python

Catalog

One 、 background

Two 、 Sudden inspiration —— The key to solving the problem

3、 ... and 、 Further growth

Four 、 Summary of knowledge points


One 、 background

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 .

Two 、 Sudden inspiration —— The key to solving the problem

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 .

3、 ... and 、 Further growth

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 !!!

Four 、 Summary of knowledge points

(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 .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved