问题
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:
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.
回答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
回答3:
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...
来源:https://stackoverflow.com/questions/9397421/error-when-running-dropbox-py