运行 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 有 755 个权限。在系统中我有 2
、2.6
版本的 python。运行 python2 dropbox.py 或 python2.6 dropbox.py 会出现相同的错误。
这是来自 Dropbox 网站的 dropbox.py 文件
每个评论更新:
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
>>>
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
>>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您的 Python 路径中还有另一个名为
collections
的模块(可能是collections.py
,但也可能是一个名为collections
的文件夹,其中包含一个>__init__.py
),这会阻止导入 Python 2.6collections
模块。可能是您调用 Python 时当前目录中的某些内容 - 首先检查那里。否则尝试 python26 -c 'import sys; print sys.path' 查看 Python 在哪里寻找模块。Looks like there's another module in your Python path named
collections
(probablycollections.py
but could also be a folder namedcollections
that has an__init__.py
in it) that's preventing the Python 2.6collections
module from being imported. Could be something in the directory that's current when you invoke Python -- check there first. Otherwise trypython26 -c 'import sys; print sys.path'
to see where Python's looking for modules.@kindall 是对的。 .dropbox-dist 文件夹包含
collections.so
,它会干扰 dropbox.py 脚本。将文件移至其他文件夹。这是一种方法:@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:您可以尝试这样做
并确保路径为
/usr/lib/python2.6/collections.pyc
。如果没有,那么 PYTHONPATH 中有另一个模块可以替代这个模块。如果是,请通过执行以下操作重试:并向我们展示结果。
通常,namedtuple 已被引入到 2.6 所以...
Can you try do to
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:And show us the result.
Normally, namedtuple have been introduced to 2.6 so...