[issue20840] AttributeError: 'module' object has no attribute 'ArgumentParser'

bsduni report at bugs.python.org
Mon Mar 3 10:05:48 CET 2014


New submission from bsduni:

Hi!

I have installed Python 2.7.6 fully (all the modules selected). I attempted run some Python codes that were developed by a past staff, and am stuck with an issue with argparse. 

For ease of explanation I am using the example given in this website at http://docs.python.org/2/howto/argparse.html.

When I create a simple program prog.py with codes below:

import argparse
parser = argparse.ArgumentParser()
parser.parse_args()

and execute with $ python prog.py, the following is the error message I receive:
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
    parser = argparse.ArgumentParser()
AttributeError: 'module' object has no attribute 'ArgumentParser'

I also tried to add argparse additionally using pip install and the problem remains the same.

Would be grateful if someone could help to overcome this AttributeError.

----------
components: Extension Modules
messages: 212620
nosy: bsduni
priority: normal
severity: normal
status: open
title: AttributeError: 'module' object has no attribute 'ArgumentParser'
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20840>
_______________________________________


More information about the Python-bugs-list mailing list