简体   繁体   English

Anaconda Python 中的 Jupyter Notebook Argparse 错误

[英]Jupyter Notebook Argparse Error in Anaconda Python

I am new in Python.我是 Python 的新手。

In this video , I got error in Anaconda Jupyter Notebook.此视频中,我在 Anaconda Jupyter Notebook 中遇到错误。

When I add this code:当我添加此代码时:

import argparse
# set up cli domain argument
parser = argparse.ArgumentParser(description="Check domain for availability")
parser.add_argument("domain", type=str, help="Domain name to be checked")
args = parser.parse_args()
print(args.domain) 

I got this error我收到了这个错误

Error错误

usage: ipykernel_launcher.py [-h] domain
ipykernel_launcher.py: error: unrecognized arguments: -f
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
C:\Users\Messi\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3377: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

How can I fix this?我怎样才能解决这个问题?

I also provide a screenshot in this link.我还在此链接中提供了屏幕截图。 . .

Thanks for your Help.谢谢你的帮助。

For some libraries, anaconda and python do not have them automatically installed, thus you must install them manually.对于某些库,anaconda 和 python 没有自动安装它们,因此您必须手动安装它们。 Ie, Pandas, Numpy, TKinter, Boto3, MatPlotLib etc must all be installed manually through the command prompt/terminal.即,Pandas、Numpy、TKinter、Boto3、Z75B5189A8F16B3B97A100DF5FDECA等都必须手动安装。

To install the argparse library on windows, try要在 windows 上安装 argparse 库,请尝试

conda install -c conda-forge argparse

In your window command prompt.在您的 window 命令提示符下。 For more details, see this link: https://anaconda.org/conda-forge/argparse有关更多详细信息,请参阅此链接: https://anaconda.org/conda-forge/argparse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM