运行 dropbox.py 时出错

发布于 2025-01-08 05:47:33 字数 1138 浏览 0 评论 0原文

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 个权限。在系统中我有 22.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

匿名。 2025-01-15 05:47:33

看起来您的 Python 路径中还有另一个名为 collections 的模块(可能是 collections.py,但也可能是一个名为 collections 的文件夹,其中包含一个 >__init__.py),这会阻止导入 Python 2.6 collections 模块。可能是您调用 Python 时当前目录中的某些内容 - 首先检查那里。否则尝试 python26 -c 'import sys; print sys.path' 查看 Python 在哪里寻找模块。

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.

苹果你个爱泡泡 2025-01-15 05:47:33

@kindall 是对的。 .dropbox-dist 文件夹包含 collections.so ,它会干扰 dropbox.py 脚本。将文件移至其他文件夹。这是一种方法:

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

@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
甜心 2025-01-15 05:47:33

您可以尝试这样做

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

并确保路径为/usr/lib/python2.6/collections.pyc。如果没有,那么 PYTHONPATH 中有另一个模块可以替代这个模块。如果是,请通过执行以下操作重试:

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

并向我们展示结果。

通常,namedtuple 已被引入到 2.6 所以...

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文