3
test@SERVER:~/source/dropbox/.dropbox-dist$ ./dropbox.py      
Traceback (most recent call last):
  File "./dropbox.py", line 39, in <module>
    import urllib
  File "/usr/lib/python2.6/urllib.py", line 30, in <module>
    from urlparse import urljoin as basejoin
  File "/usr/lib/python2.6/urlparse.py", line 84, in <module>
    from collections import namedtuple
ImportError: cannot import name namedtuple

dropbox.py has 755 perms. In system I have 2, 2.6 versions of python. Running python2 dropbox.py or python2.6 dropbox.py spits the same error.

and here is dropbox.py file from Dropbox website

Update per comment:

test@SERVER:~/source/dropbox/.dropbox-dist$ python2.6
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import namedtuple
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name namedtuple
>>> 
1
  • What happens if you try from collections import namedtuple in the python2.6 IDE? And could you please post the header of that IDE session? Commented Feb 22, 2012 at 15:19

3 Answers 3

9

Looks like there's another module in your Python path named collections (probably collections.py but could also be a folder named collections that has an __init__.py in it) that's preventing the Python 2.6 collections module from being imported. Could be something in the directory that's current when you invoke Python -- check there first. Otherwise try python26 -c 'import sys; print sys.path' to see where Python's looking for modules.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case, I had put dropbox.py in the .dropbox-dist/ folder. This was causing the error. As soon as I moved it outside the folder, it worked fine.
2

@kindall was right. The .dropbox-dist folder contains collections.so which interferes with the dropbox.py script. Move the file to a different folder. Here is one way:

mkdir cli
mv dropbox.py cli/dropbox.py
cd cli
./dropbox.py --help

Comments

1

Can you try do to

python -c 'import collections; print collections.__file__'

And ensure that the path is /usr/lib/python2.6/collections.pyc. If not, then you have another modules in your PYTHONPATH that replace this one. If yes, then try again by doing:

python -c 'import collections; print dir(collections)'

And show us the result.

Normally, namedtuple have been introduced to 2.6 so...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.