Bugs in import labelbox as lb

When I import your labelbox installed by pip3 install “labelbox[data]” or just pip3 install labelbox - doesn’t metter I have the following issue: TypeError: descriptor ‘deepcopy’ for ‘numpy.ndarray’ objects doesn’t apply to a ‘dict’ object.

It happends just on import row!

I’m already reinstall environments, labelbox - doesn’t work anyway.

Hello @egorsurkov ,

Could you provide the Python version you are using as well as the full stack trace?
If you have numpy already installed can you provide the version as well?
Any details about your setup can be pertinent here (OS, env type such as conda…)

Many thanks,
PT
Labelbox Support

Thank you for your reply.

Of course.
Numpy version: 1.25.2
I created a clean environment by pip3. No conda. OS - mac os.
Python 3.9
I used your package earlier, but now this error. I don’t know why.
Traceback from python console:
import labelbox as lb
Traceback (most recent call last):
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py”, line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1, in
import labelbox as lb
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/init.py”, line 4, in
from labelbox.client import Client
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/client.py”, line 24, in
from labelbox.schema.data_row_metadata import DataRowMetadataOntology
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/schema/init.py”, line 14, in
import labelbox.schema.project
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/schema/project.py”, line 43, in
from labelbox.data.serialization import LBV1Converter
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/init.py”, line 1, in
from .labelbox_v1 import LBV1Converter
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/init.py”, line 1, in
from .converter import LBV1Converter
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/converter.py”, line 1, in
from labelbox.data.serialization.labelbox_v1.objects import LBV1Mask
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/objects.py”, line 10, in
from .classification import LBV1Checklist, LBV1Classifications, LBV1Radio, LBV1Text, LBV1Dropdown
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/classification.py”, line 5, in
from .feature import LBV1Feature
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/feature.py”, line 6, in
from …annotation_types.types import Cuid
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/init.py”, line 1, in
from .geometry import Line
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/geometry/init.py”, line 3, in
from .mask import Mask
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/geometry/mask.py”, line 9, in
from …data import MaskData
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/data/init.py”, line 6, in
from .raster import ImageData
File “/Users/egorsurkov/Library/Application Support/JetBrains/Toolbox/apps/DataSpell/ch-0/231.9225.14/DataSpell.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “/Users/egorsurkov/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/data/raster.py”, line 196, in
class MaskData(RasterData):
File “pydantic/main.py”, line 138, in pydantic.main.ModelMetaclass.new
File “pydantic/utils.py”, line 693, in pydantic.utils.smart_deepcopy
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 146, in deepcopy
y = copier(x, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 270, in _reconstruct
state = deepcopy(state, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 146, in deepcopy
y = copier(x, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 210, in _deepcopy_tuple
y = [deepcopy(a, memo) for a in x]
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 210, in
y = [deepcopy(a, memo) for a in x]
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 146, in deepcopy
y = copier(x, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py”, line 153, in deepcopy
y = copier(memo)
TypeError: descriptor ‘deepcopy’ for ‘numpy.ndarray’ objects doesn’t apply to a ‘dict’ object

Traceback from cell

TypeError Traceback (most recent call last)
Cell In[18], line 1
----> 1 import labelbox as lb

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/init.py:4
1 name = “labelbox”
2 version = “3.51.0”
----> 4 from labelbox.client import Client
5 from labelbox.schema.project import Project
6 from labelbox.schema.model import Model

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/client.py:27
25 from labelbox.schema.dataset import Dataset
26 from labelbox.schema.enums import CollectionJobStatus
—> 27 from labelbox.schema.iam_integration import IAMIntegration
28 from labelbox.schema import role
29 from labelbox.schema.labeling_frontend import LabelingFrontend

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/schema/init.py:14
12 import labelbox.schema.ontology
13 import labelbox.schema.organization
—> 14 import labelbox.schema.project
15 import labelbox.schema.review
16 import labelbox.schema.role

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/schema/project.py:43
40 MonkeyPatch.patch_fromisoformat()
42 try:
—> 43 from labelbox.data.serialization import LBV1Converter
44 except ImportError:
45 pass

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/init.py:1
----> 1 from .labelbox_v1 import LBV1Converter
2 from .ndjson import NDJsonConverter
3 from .coco import COCOConverter

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/init.py:1
----> 1 from .converter import LBV1Converter

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/converter.py:1
----> 1 from labelbox.data.serialization.labelbox_v1.objects import LBV1Mask
2 from typing import Any, Dict, Generator, Iterable, Union
3 import logging

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/objects.py:10
7 from pydantic import BaseModel, validator, Field
8 import numpy as np
—> 10 from .classification import LBV1Checklist, LBV1Classifications, LBV1Radio, LBV1Text, LBV1Dropdown
11 from .feature import LBV1Feature
12 from …annotation_types.annotation import (ClassificationAnnotation,
13 ObjectAnnotation)

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/serialization/labelbox_v1/classification.py:6
3 from pydantic.main import BaseModel
5 from .feature import LBV1Feature
----> 6 from …annotation_types.annotation import ClassificationAnnotation
7 from …annotation_types.classification import Checklist, ClassificationAnswer, Radio, Text, Dropdown
8 from …annotation_types.types import Cuid

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/init.py:1
----> 1 from .geometry import Line
2 from .geometry import Point
3 from .geometry import Mask

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/geometry/init.py:3
1 from .line import Line
2 from .point import Point
----> 3 from .mask import Mask
4 from .polygon import Polygon
5 from .rectangle import Rectangle

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/geometry/mask.py:9
5 import cv2
7 from shapely.geometry import MultiPolygon, Polygon
----> 9 from …data import MaskData
10 from .geometry import Geometry
13 class Mask(Geometry):

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/data/init.py:6
4 from .document import DocumentData
5 from .html import HTMLData
----> 6 from .raster import ImageData
7 from .raster import MaskData
8 from .text import TextData

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/labelbox/data/annotation_types/data/raster.py:196
192 # Required for discriminating between data types
193 extra = ‘forbid’
→ 196 class MaskData(RasterData):
197 “”“Used to represent a segmentation Mask
198
199 All segments within a mask must be mutually exclusive. At a
(…)
214 arr: Optional[TypedArray[Literal[‘uint8’]]] = None
215 “””
218 class ImageData(RasterData, BaseData):

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/pydantic/main.py:138, in pydantic.main.ModelMetaclass.new()

File ~/git-ps/projects/python/labelbox-export/venv/lib/python3.9/site-packages/pydantic/utils.py:693, in pydantic.utils.smart_deepcopy()

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:146, in deepcopy(x, memo, _nil)
144 copier = _deepcopy_dispatch.get(cls)
145 if copier is not None:
→ 146 y = copier(x, memo)
147 else:
148 if issubclass(cls, type):

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:230, in _deepcopy_dict(x, memo, deepcopy)
228 memo[id(x)] = y
229 for key, value in x.items():
→ 230 y[deepcopy(key, memo)] = deepcopy(value, memo)
231 return y

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:172, in deepcopy(x, memo, _nil)
170 y = x
171 else:
→ 172 y = _reconstruct(x, memo, *rv)
174 # If is its own copy, don’t memoize.
175 if y is not x:

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:270, in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
268 if state is not None:
269 if deep:
→ 270 state = deepcopy(state, memo)
271 if hasattr(y, ‘setstate’):
272 y.setstate(state)

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:146, in deepcopy(x, memo, _nil)
144 copier = _deepcopy_dispatch.get(cls)
145 if copier is not None:
→ 146 y = copier(x, memo)
147 else:
148 if issubclass(cls, type):

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:210, in _deepcopy_tuple(x, memo, deepcopy)
209 def _deepcopy_tuple(x, memo, deepcopy=deepcopy):
→ 210 y = [deepcopy(a, memo) for a in x]
211 # We’re not going to put the tuple in the memo, but it’s still important we
212 # check for it, in case the tuple contains recursive mutable structures.
213 try:

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:210, in (.0)
209 def _deepcopy_tuple(x, memo, deepcopy=deepcopy):
→ 210 y = [deepcopy(a, memo) for a in x]
211 # We’re not going to put the tuple in the memo, but it’s still important we
212 # check for it, in case the tuple contains recursive mutable structures.
213 try:

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:146, in deepcopy(x, memo, _nil)
144 copier = _deepcopy_dispatch.get(cls)
145 if copier is not None:
→ 146 y = copier(x, memo)
147 else:
148 if issubclass(cls, type):

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:230, in _deepcopy_dict(x, memo, deepcopy)
228 memo[id(x)] = y
229 for key, value in x.items():
→ 230 y[deepcopy(key, memo)] = deepcopy(value, memo)
231 return y

File /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/copy.py:153, in deepcopy(x, memo, _nil)
151 copier = getattr(x, “deepcopy”, None)
152 if copier is not None:
→ 153 y = copier(memo)
154 else:
155 reductor = dispatch_table.get(cls)

TypeError: descriptor ‘deepcopy’ for ‘numpy.ndarray’ objects doesn’t apply to a ‘dict’ object

Did you have a time to check my tracebacks?:slight_smile:

Could you confirm your Mac processor? is it an M1/M2?
Also can you provide the result of pip freeze

M1 processor

pip freeze:

anyio==3.7.1
appnope==0.1.3
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
async-lru==2.0.4
attrs==23.1.0
Babel==2.12.1
backcall==0.2.0
backoff==1.10.0
beautifulsoup4==4.12.2
bleach==6.0.0
cachetools==5.3.1
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
comm==0.1.4
debugpy==1.6.7.post1
decorator==5.1.1
defusedxml==0.7.1
exceptiongroup==1.1.3
executing==1.2.0
fastjsonschema==2.18.0
fqdn==1.5.1
geojson==3.0.1
google-api-core==2.11.1
google-auth==2.22.0
googleapis-common-protos==1.60.0
idna==3.4
imagesize==1.4.1
importlib-metadata==6.8.0
ipykernel==6.25.1
ipython==8.14.0
ipython-genutils==0.2.0
ipywidgets==8.1.0
isoduration==20.11.0
jedi==0.19.0
Jinja2==3.1.2
json5==0.9.14
jsonpointer==2.4
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.7.0
jupyter-lsp==2.2.0
jupyter_client==8.3.0
jupyter_core==5.3.1
jupyter_server==2.7.2
jupyter_server_terminals==0.4.4
jupyterlab==4.0.5
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.8
jupyterlab_server==2.24.0
labelbox==3.51.0
MarkupSafe==2.1.3
matplotlib-inline==0.1.6
mistune==3.0.1
nbclient==0.8.0
nbconvert==7.7.4
nbformat==5.9.2
nest-asyncio==1.5.7
notebook==7.0.2
notebook_shim==0.2.3
numpy==1.25.2
opencv-python==4.8.0.76
overrides==7.4.0
packaging==23.1
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==10.0.0
platformdirs==3.10.0
prometheus-client==0.17.1
prompt-toolkit==3.0.39
protobuf==4.24.1
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
pydantic==1.10.12
pyGeoTile==1.0.6
Pygments==2.16.1
pyproj==3.6.0
python-dateutil==2.8.2
python-json-logger==2.0.7
PyYAML==6.0.1
pyzmq==25.1.1
qtconsole==5.4.3
QtPy==2.3.1
referencing==0.30.2
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.9.2
rsa==4.9
Send2Trash==1.8.2
shapely==2.0.1
six==1.16.0
sniffio==1.3.0
soupsieve==2.4.1
stack-data==0.6.2
terminado==0.17.1
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.3
tqdm==4.66.1
traitlets==5.9.0
typeguard==4.1.2
typing_extensions==4.7.1
uri-template==1.3.0
urllib3==1.26.16
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.2
widgetsnbextension==4.0.8
zipp==3.16.2

Could you create a new env with only numpy and Labelbox installed in that order please and let me know how it goes?

But that’s jupyter’s staff. If I delete it how I run it?

You can also add jupyter or Jupiter lab, those are not the issue here (I used them myself) but in case you can also call the package via the interpreter :

python3.9 2023-08-24 14-19-54

Yes it works if I call it by the interpreter