4

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.

Jason C
  • 38,729
  • 14
  • 126
  • 182
user3236698
  • 51
  • 1
  • 1
  • 4
  • I've installed `argparse` on python2.6 lots of times. It's a pure python module and there shouldn't be any real problems with it. How did you install it? – mgilson Jan 26 '14 at 03:47
  • 4
    As a sanity check, are you able to `import` any other modules from your `site-packges`? – chrisaycock Jan 26 '14 at 03:49
  • 1
    `>>> import sys, pprint; pprint.pprint(sys.path)` see if you have the path site-packages there... – recognosco Jan 26 '14 at 04:30
  • from the python interactive shell can you do `import argparse` do you got the same error. – James Sapam Jan 26 '14 at 05:02
  • Also `pip freeze | grep argparse` should output `argparse==1.2.1`. – iljau Jan 26 '14 at 05:48
  • @mgilson I used easy_install argparse – user3236698 Jan 26 '14 at 19:36
  • @recognosco result: >>> import sys, pprint; pprint.pprint(sys.path) ['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info'] – user3236698 Jan 26 '14 at 19:39
  • @yopy ... Yes, the same error – user3236698 Jan 26 '14 at 19:49
  • @iljau Doesn't work - I get the same error. – user3236698 Jan 26 '14 at 19:50
  • 1
    And from output of `import sys, pprint; pprint.pprint(sys.path)` it looks like your 32-bit and 64-bit `site-packages` are mixed for some reason. – iljau Jan 26 '14 at 19:57
  • It looks like `argparse` is installed for 32-bit python, while default python interpreter is 64-bit. I'd try installing `argparse` using 64-bit version of `pip` or `easy_install`. Or then explicitly invoke 32-bit `python`. – iljau Jan 26 '14 at 20:01
  • @iljau I agree that the 32bit/64bit is probably the problem. However, I assumed that easy_install would take care of sorting this out. How do I explicitly install the 64 bit argparse? – user3236698 Jan 26 '14 at 20:19
  • ["Howto install 32-bit libraries on 64-bit Linux using yum"](http://www.linuxquestions.org/questions/linux-server-73/howto-install-32-bit-libraries-on-64-bit-linux-using-yum-505352/) may give some vague pointers. – iljau Jan 26 '14 at 21:32

4 Answers4

5

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

Community
  • 1
  • 1
iljau
  • 2,151
  • 3
  • 22
  • 45
  • According to the question, he's already installed the backport. Notice "/usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg" in his list of required packages. – abarnert Jan 26 '14 at 04:49
  • // , This worked for me, too. Make sure that argparse.py has the right owner, and that it is set as executable. Check @user3236698's answer for more about this. – Nathan Basanese Sep 03 '15 at 21:41
5

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.

Josh
  • 2,790
  • 26
  • 30
Jasem Elayeb
  • 77
  • 1
  • 2
1

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>
user3236698
  • 51
  • 1
  • 1
  • 4
0

Looks like argparse is missing.

yum install python-argparse
Sidharth
  • 1
  • 1