Error starting 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 perm. On the system, I have 2 , 2.6 versions of python. Running python2 dropbox.py or python2.6 dropbox.py results in the same error.

and here is the dropbox.py file from Dropbox

Update for 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 >>> 
+4
source share
4 answers

It looks like there is another module in your Python path called collections (maybe collections.py , but it could also be a folder called collections that has __init__.py ), which prevents the use of the Python 2.6 module module being imported. Maybe there is something in the directory that is current when you call Python - check there first. Otherwise try python26 -c 'import sys; print sys.path' python26 -c 'import sys; print sys.path' to see where Python is looking for modules.

+9
source

@kindall was right. The .dropbox-dist folder contains collections.so , which prevents the dropbox.py script. Move the file to another folder. Here is one way:

 mkdir cli mv dropbox.py cli/dropbox.py cd cli ./dropbox.py --help 
+2
source

Can you try to do

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

And make sure the path is /usr/lib/python2.6/collections.pyc . If not, then you have another module in PYTHONPATH that will replace this. If yes, try again:

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

And show us the result.

Typically, namedtuple was introduced in 2.6, so ...

0
source

I introduced the following sentence in a python environment in OPENSUSE12.3 import matplotlib.pyplot

and the following: stdout errors:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/matplotlib/__init__.py", line 123, in <module> import os, re, shutil, warnings File "/usr/lib/python2.7/shutil.py", line 12, in <module> import collections File "collections.py", line 13, in <module> import numpy as np File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module> from . import add_newdocs File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 6, in <module> from .type_check import * File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 46, in <module> from numpy.testing import Tester File "/usr/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module> from unittest import TestCase File "/usr/lib/python2.7/unittest/__init__.py", line 58, in <module> from .result import TestResult File "/usr/lib/python2.7/unittest/result.py", line 9, in <module> from . import util File "/usr/lib/python2.7/unittest/util.py", line 2, in <module> from collections import namedtuple, OrderedDict ImportError: cannot import name namedtuple 

I just have a similar problem. As a rookie, I don’t know how to solve it, even I read the advice. Could you give me some convenient and simple explanations and solutions. Thanks u!

-2
source

Source: https://habr.com/ru/post/1397839/


All Articles