TypeError: ArgumentParser.__init__() got an unexpected keyword argument 'allow_abbrev'

Hi, all:

  1. From argparse’s Python Oiffice Documentation, there is an argument allow_abbrev - Allows long options to be abbreviated if the abbreviation is unambiguous. (default: True), which clearly mentioned requiring Python 3.5 or above.

  2. However, by pip install argparse -U, which should be https://pypi.org/project/argparse/, I got the above error as titled TypeError: ArgumentParser.__init__() got an unexpected keyword argument 'allow_abbrev' . This is understandable, for argparse on pypi hasn’t been updated since 2015, before Python 3.5.

  3. What is the most up-to-date version of argparse now?

Conclusion: where and how can I help to update, or at least, pull request for Python pip packages?

Thank you

The most up-to-date version is the one already installed with Python. The page you linked to specifically says that this is compatible with a limited set of Python versions and is unnecessary if you’re on Python 3.2 or newer (which is pretty ancient now). If you uninstall the one you got from pip, you should see the standard library version instead; in fact, all of the documentation that you’re seeing there is for the things that are already part of Python and don’t need to be installed.

The good news is, you don’t need to go to any effort to get argparse! The bad news is, you might need to clean out the one you already got - try “pip uninstall argparse”. :slight_smile:

1 Like