Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.6 ImportError: No module named argparse

I'm trying to run git-cola from Red Hat Enterprise Linux Server release 6.5 and receive:

Traceback (most recent call last):
File "....../bin/git-cola", line 24, in <module>
from argparse import ArgumentParser
ImportError: No module named argparse

I think I have all of the required packages installed:

* git-1.7.1-3.el6_4.1.x86_64
* python-2.6.6-51.el6.x86_64
* PyQt4.x86_64 0:4.6.2-9.el6
* /usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg

I read in other blogs that there may be a problem with Python 2.6 and may need to move to 2.7.

Additional information - @iljau noticed that argparse is in a 32 bit lib, while the rest of python is in 64 bits. I would have expected that:

easy_install argparse

would have sorted this out and installed the 64 bit version.

Additional question: Does anyone know how to install the 64 bit version of argparse. It is not apparent to me from searching the internet. I will continue looking.

I installed argparse by downloading the tar file and

python setup.py install

However, it still installed it in the lib rather than lib64 path - and it looks like a 64 bit install. So something else must be the problem in referencing argparse properly. I don't know Python enough to debug it, but I suspect that git-cola needs some work for Python 2.6.

like image 369
user3236698 Avatar asked Dec 20 '22 18:12

user3236698


2 Answers

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".

like image 188
iljau Avatar answered Dec 29 '22 16:12

iljau


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.

like image 45
Jasem Elayeb Avatar answered Dec 29 '22 16:12

Jasem Elayeb