TypeError when importing imageio
See original GitHub issueI get the following traceback when importing imageio. It’s my first time using it, so I’m not 100% sure of version compatibilities.
----> 1 import imageio as iio
File ~/miniforge3/lib/python3.9/site-packages/imageio/__init__.py:24, in <module>
21 import warnings
23 # Load some bits from core
---> 24 from .core import FormatManager, RETURN_BYTES
26 # Instantiate the old format manager
27 formats = FormatManager()
File ~/miniforge3/lib/python3.9/site-packages/imageio/core/__init__.py:16, in <module>
14 from .fetching import get_remote_file, InternetNotAllowedError, NeedDownloadError
15 from .request import Request, read_n_bytes, RETURN_BYTES
---> 16 from .format import Format, FormatManager
File ~/miniforge3/lib/python3.9/site-packages/imageio/core/format.py:40, in <module>
38 from . import Array, asarray
39 from .request import ImageMode
---> 40 from ..config import known_plugins, known_extensions, PluginConfig, FileExtension
41 from ..config.plugins import _original_order
42 from .imopen import imopen
File ~/miniforge3/lib/python3.9/site-packages/imageio/config/__init__.py:7, in <module>
1 from .extensions import (
2 extension_list,
3 known_extensions,
4 FileExtension,
5 video_extensions,
6 )
----> 7 from .plugins import known_plugins, PluginConfig
9 __all__ = [
10 "known_plugins",
11 "PluginConfig",
(...)
15 "video_extensions",
16 ]
File ~/miniforge3/lib/python3.9/site-packages/imageio/config/plugins.py:3, in <module>
1 import importlib
----> 3 from ..core.legacy_plugin_wrapper import LegacyPlugin
6 class PluginConfig:
7 """Plugin Configuration Metadata
8
9 This class holds the information needed to lazy-import plugins.
(...)
50
51 """
File ~/miniforge3/lib/python3.9/site-packages/imageio/core/legacy_plugin_wrapper.py:5, in <module>
2 from pathlib import Path
4 from .request import IOMode, InitializationError
----> 5 from .v3_plugin_api import PluginV3, ImageProperties
8 def _legacy_default_index(format):
9 if format._name == "FFMPEG":
File ~/miniforge3/lib/python3.9/site-packages/imageio/core/v3_plugin_api.py:2, in <module>
1 from . import Request
----> 2 from ..typing import ArrayLike
3 import numpy as np
4 from typing import Optional, Dict, Any, Tuple, Union, List, Iterator
File ~/miniforge3/lib/python3.9/site-packages/imageio/typing.py:6, in <module>
3 from pathlib import Path
5 try:
----> 6 from numpy.typing import ArrayLike
7 except ImportError:
8 # numpy<1.20 fall back to using ndarray
9 from numpy import ndarray as ArrayLike
File ~/miniforge3/lib/python3.9/site-packages/numpy/typing/__init__.py:324, in <module>
311 from ._scalars import (
312 _CharLike_co,
313 _BoolLike_co,
(...)
321 _VoidLike_co,
322 )
323 from ._shape import _Shape, _ShapeLike
--> 324 from ._dtype_like import (
325 DTypeLike as DTypeLike,
326 _SupportsDType,
327 _VoidDTypeLike,
328 _DTypeLikeBool,
329 _DTypeLikeUInt,
330 _DTypeLikeInt,
331 _DTypeLikeFloat,
332 _DTypeLikeComplex,
333 _DTypeLikeTD64,
334 _DTypeLikeDT64,
335 _DTypeLikeObject,
336 _DTypeLikeVoid,
337 _DTypeLikeStr,
338 _DTypeLikeBytes,
339 _DTypeLikeComplex_co,
340 )
341 from ._array_like import (
342 ArrayLike as ArrayLike,
343 _ArrayLike,
(...)
358 _ArrayLikeBytes_co,
359 )
360 from ._generic_alias import (
361 NDArray as NDArray,
362 _DType,
363 _GenericAlias,
364 )
File ~/miniforge3/lib/python3.9/site-packages/numpy/typing/_dtype_like.py:16, in <module>
13 import numpy as np
15 from ._shape import _ShapeLike
---> 16 from ._generic_alias import _DType as DType
18 from ._char_codes import (
19 _BoolCodes,
20 _UInt8Codes,
(...)
57 _ObjectCodes,
58 )
60 _DTypeLikeNested = Any # TODO: wait for support for recursive types
File ~/miniforge3/lib/python3.9/site-packages/numpy/typing/_generic_alias.py:211, in <module>
208 ScalarType = TypeVar("ScalarType", bound=np.generic, covariant=True)
210 if TYPE_CHECKING or sys.version_info >= (3, 9):
--> 211 _DType = np.dtype[ScalarType]
212 NDArray = np.ndarray[Any, np.dtype[ScalarType]]
213 else:
TypeError: 'type' object is not subscriptable
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Importing moviepy editor gives typeerror - Stack Overflow
When I try to import the moviepy packagage I get the following type error. import moviepy.editor as mpy. Output: File ~\Miniconda3\envs\ ...
Read more >imageio > 2.9.0 breaks ImageInput #2084 - bentoml ... - GitHub
Describe the bug If using imageio > 2.9.0 this breaks ImageInput To ... e.g. from bentoml import api, BentoService from bentoml.adapters ...
Read more >imageio Documentation - Read the Docs
import imageio.v3 as iio. # index=None means: read all images in the file and stack along first axis frames = iio.imread("imageio:newtonscradle.gif", ...
Read more >Installing imageio — imageio 2.6.1 documentation
For developers, we provide a simple mechanism to allow importing imageio from the cloned repository. See the file imageio.proxy.py for details.
Read more >Importing Image Data into NumPy Arrays | Pluralsight
Loading and displaying an image using Matplotlib, OpenCV and Keras API. Converting the loaded images to the NumPy array and back. Conducting ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that is expected. The
typing
module was introduced in numpy 1.20, so if you are using an earlier version of numpy (1.19.5) then you simply won’t have it.For ImageIO this is not a problem (we have a fallback for that case), so you should be good to go 😃
Since that solves the problem, I will go ahead and close this issue. If there is more on this topic, please comment and I can reopen. Also, feel free to let us know if you find any bugs or have suggestions for improvement.
Yes, 3.9.12.
So not sure what was the issue, I guess at some point I had numpy installed through pip in that env? And when I uninstalled it with pip and tried to install it through conda it read #All requested packages already installed. Then I checked for a
conda list numpy
and there it was in version 1.19.5 in the conda-forge channel all along! (I thought that packages in the conda-forge channel were superseded because of higher priority(?)).Also, after fixing the versions, when I checked for
numpy.typing.ArrayLike
I now get this:Either way, imageio is now being imported correctly 😃 Thank you for your time @FirefoxMetzger !