简体   繁体   English

运行dropbox.py时出错

[英]Error when running dropbox.py

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. dropbox.py有755个烫发。 In system I have 2 , 2.6 versions of python. 在系统中我有22.6版本的python。 Running python2 dropbox.py or python2.6 dropbox.py spits the same error. 运行python2 dropbox.pypython2.6 dropbox.py发出同样的错误。

and here is dropbox.py file from Dropbox website 这是来自Dropbox网站的dropbox.py文件

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

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. 看起来你的Python路径中有另一个名为collections模块(可能是collections.py但也可能是一个名为collections的文件夹,里面有__init__.py ),这阻止了Python 2.6 collections模块的导入。 Could be something in the directory that's current when you invoke Python -- check there first. 当你调用Python时,可能是当前目录中的某些内容 - 请先检查一下。 Otherwise try python26 -c 'import sys; print sys.path' 否则试试python26 -c 'import sys; print sys.path' python26 -c 'import sys; print sys.path' to see where Python's looking for modules. python26 -c 'import sys; print sys.path'查看Python在哪里寻找模块。

@kindall was right. @kindall是对的。 The .dropbox-dist folder contains collections.so which interferes with the dropbox.py script. .dropbox-dist文件夹包含collections.so ,它会干扰dropbox.py脚本。 Move the file to a different folder. 将文件移动到其他文件夹。 Here is one way: 这是一种方式:

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

Can you try do to 你能试试吗?

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

And ensure that the path is /usr/lib/python2.6/collections.pyc . 并确保路径为/usr/lib/python2.6/collections.pyc If not, then you have another modules in your PYTHONPATH that replace this one. 如果没有,那么你的PYTHONPATH中有另一个模块可以替换这个模块。 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... 通常,namedtuple已被引入2.6所以...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM