Python 2.6 ImportError: No module named argparse

泪湿孤枕 提交于 2019-12-05 15:05:23
iljau

As a simple solution copy argparse.py from https://code.google.com/p/argparse/source/browse/argparse.py to your project folder.


And indeed, for Python 2.6 argparse needs to be installed separately.

From: https://pypi.python.org/pypi/argparse

As of Python >= 2.7 .. the argparse module is maintained within the Python standard library. For users who still need to support Python < 2.7 .. it is also provided as a separate package, which .. also supports older Python versions.

But even after you install argparse, it may refuse to work for some mysterious reasons.

Additional debugging tips may be found in answers and comments to question "ImportError: No module named argparse".

Jasem Elayeb

I had the same problem on RHEL6 and the solution was installing the package python-argparse.noarch:

yum install python-argparse.noarch

then everything was fine.

The new packages were installed in the path:

/usr/lib/python2.6/site-packages

Installing them with sudo left the newly installed directories and files unreadable by all. A recursive chmod to open all the installed paths as readable to all solved the problem:

chmod -R u+rwX,go+rX,go-w <new directories and files>

Looks like argparse is missing.

yum install python-argparse
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!