nutonomy / nuscenes-devkit

The devkit of the nuScenes dataset.
https://www.nuScenes.org
Other
2.2k stars 617 forks source link

`nuscenes-devkit` raises `TypeError` depending on `opncv-python` and `numpy` version #968

Closed ktro2828 closed 11 months ago

ktro2828 commented 11 months ago

Hi, I encountered the following error. This is occurred depending on the version mismatch of opencv-python and numpy.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 175, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.10/dist-packages/cv2/typing/__init__.py", line 69, in <module>
    NumPyArrayGeneric = numpy.ndarray[typing.Any, numpy.dtype[numpy.generic]]
TypeError: 'numpy._DTypeMeta' object is not subscriptable

I found that this error happens if opencv-python==4.8.0.76 (latest version) and numpy<1.22.0. Because, in ubuntu-22.04, numpy==1.21.5 is installed by defaults pip does not install newer version of numpy, then this error occurs. The related issue in opencv is here.

Although nuscenes-devkit does not specify the versions of opencv-python and numpy, how about specifying the version of opencv-python and numpy explicitly, or do you have any ideas to avoid this?

ktro2828 commented 11 months ago

I created a PR to specify numpy>=1.22.0 and opencv-python>=4.5.4.58, please check it! https://github.com/nutonomy/nuscenes-devkit/pull/969

whyekit-motional commented 11 months ago

@ktro2828 thanks for pointing out the issue and opening a PR :+1: I've approved and merged your PR

ktro2828 commented 10 months ago

@whyekit-motional Thanks for merging! I want to install nuscenes-devkit after this PR is merged via pip or rosdep, so could you update the source distribution? https://pypi.org/project/nuscenes-devkit/#modal-close

whyekit-motional commented 10 months ago

@ktro2828 apologies for the late reply - I've now released v1.1.11