python - 试图将图像传递给代码以进行进一步处理并在 Python 中遇到 argparse 问题?
问题描述
这都是关于使用argparse
python将图像传递给数据集
import argparse
import imutils
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--input", required=True,
help="path to input image")
ap.add_argument("-o", "--output", required=True,
help="path to output image")
args = vars(ap.parse_args()) #here is where the problem occured
应该没有任何错误,作为初学者我无法理解这个错误:
usage: [-h] -i INPUT -o OUTPUT
: error: the following arguments are required: -i/--input, -o/--output
An exception has occurred, use %tb to see the full traceback.
%tb
Traceback (most recent call last):
File "<ipython-input-26-269e7792981c>", line 11, in <module>
args = vars(ap.parse_args())
File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 1734, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 1766, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2001, in _parse_known_args
', '.join(required_actions))
File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2393, in error
self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2380, in exit
_sys.exit(status)
SystemExit: 2
解决方案
推荐阅读
- knex.js - knex.raw.query() 使用 ORDER BY 绑定给出错误
- python - 为什么从文件中导入的 python 文件调用函数后 PyQt 应用程序停止响应?
- php - 类 admin 不存在 Laravel
- docker - jenkins 无法安装插件 - docker image
- ssh - 使用 ssh 时如何在本地键入命令?
- java - onDraw 未在添加到与 Windows 管理器叠加的自定义视图中调用
- python - 如何从给定列表中获得字符串“OFF”的索引。我尝试使用 if 语句遍历列表,但没有成功
- perl - Perl 如何存储和执行菜单命令?
- scala - 案例类的 DAG
- python - 有没有办法可以将 pandas 列的值设置为字典?