How can I get argparse in Python 2.6?

Bitwise picture Bitwise · Mar 11, 2013 · Viewed 63.3k times · Source

I have some Python 2.7 code written that uses the argparse module. Now I need to run it on a Python 2.6 machine and it won't work since argparse was added in 2.7.

Is there anyway I can get argparse in 2.6? I would like to avoid rewriting the code, since I will be transferring this kind of code between the machines often. Upgrading python is not an option.

I should have clarified that the ideal solution would be something that does not require module installation.

Answer

user3517231 picture user3517231 · Apr 9, 2014

On Centos, Scientific, or Redhat, you can fix this by running the command:for

yum install python-argparse