No module named 'torchvision.transforms.functional_tensor', cannot import name 'read_video' (or any name) from 'torchvision...': which torchvision releases have it
torchvision 0.17.0 (2024-01-30) removed torchvision.transforms.functional_tensor (0.16.x is the last with it), and 0.26.0 (2026-03-23) removed video decoding (torchvision.io.read_video, VideoReader). The first breaks basicsr, and with it Real-ESRGAN and GFPGAN: change from torchvision.transforms.functional_tensor import rgb_to_grayscale to from torchvision.transforms.functional import rgb_to_grayscale, or pin torchvision<0.17. For video, use TorchCodec or pin torchvision<0.26. Each torchvision pins one torch release, so pinning torchvision pins torch too: the table below lists every pair. For any other name, paste the error below.
Corrected on 2026-12-05: this page read only the first release of each minor version, so a name added or removed in a patch release was dated to the next minor. For example, torchvision.set_video_backend is in 0.4.2 (2019-11-07), not only from 0.5.0, and the torchvision.prototype package of the 0.16.0 wheel is gone again in 0.16.1. Every release was then read once from PyPI: 5 top-level names (and 1,392 module-and-name pairs in all) differ in some patch release from the first release of the same minor. The lookup now gives those patch releases. The per-minor ranges are unchanged.
Examples:
Runs in your browser on torchvision.json (243 KB) and 12 KB of hints in this page; nothing you paste is sent anywhere. Covers 7,344 module-and-name pairs in 252 modules (69 of them gone).
What do I import instead?
| Fails | Gone in | Instead |
|---|---|---|
torchvision.transforms.functional_tensor, functional_pil | 0.17.0 | torchvision.transforms.functional (or transforms.v2.functional) |
torchvision.io.read_video, read_video_timestamps, write_video, VideoReader | 0.26.0 | TorchCodec (torchcodec.decoders.VideoDecoder), or pin torchvision<0.26 |
torchvision.models.utils.load_state_dict_from_url | 0.11 | torch.hub.load_state_dict_from_url |
torchvision.datapoints | 0.16.0 | torchvision.tv_tensors |
transforms.v2.ToImageTensor, ConvertDtype | 0.16.0 | ToImage, ToDtype |
transforms.Scale, RandomSizedCrop | 0.12.0 | Resize, RandomResizedCrop |
datasets.Kinetics400 | 0.14.0 | datasets.Kinetics(..., num_classes="400") |
torchvision 0.11.0 and 0.15.0 were yanked from PyPI, so the first releases of those minors here are 0.11.1 and 0.15.1. The 0.16.0 and 0.22.0 wheels also carry a torchvision.prototype package that the other releases do not.
Which torchvision goes with my torch?
Every torchvision wheel on PyPI requires one exact torch release, so pip install torchvision without a version can change your torch. From 0.29.1 the requirement is torch>=2.14.0. Read from the Requires-Dist line of each wheel's metadata (Linux x86_64):
| Minor | torchvision releases | Requires |
|---|---|---|
| 0.29 | 0.29.0, 0.29.1, 0.29.2 | torch>=2.14.0, torch==2.14.0 |
| 0.28 | 0.28.0 | torch==2.13.0 |
| 0.27 | 0.27.0, 0.27.1 | torch==2.12.0, torch==2.12.1 |
| 0.26 | 0.26.0 | torch==2.11.0 |
| 0.25 | 0.25.0 | torch==2.10.0 |
| 0.24 | 0.24.0, 0.24.1 | torch==2.9.0, torch==2.9.1 |
| 0.23 | 0.23.0 | torch==2.8.0 |
| 0.22 | 0.22.0, 0.22.1 | torch==2.7.0, torch==2.7.1 |
| 0.21 | 0.21.0 | torch==2.6.0 |
| 0.20 | 0.20.0, 0.20.1 | torch==2.5.0, torch==2.5.1 |
| 0.19 | 0.19.0, 0.19.1 | torch==2.4.0, torch==2.4.1 |
| 0.18 | 0.18.0, 0.18.1 | torch==2.3.0, torch==2.3.1 |
| 0.17 | 0.17.0, 0.17.1, 0.17.2 | torch==2.2.0, torch==2.2.1, torch==2.2.2 |
| 0.16 | 0.16.0, 0.16.1, 0.16.2 | torch==2.1.0, torch==2.1.1, torch==2.1.2 |
| 0.15 | 0.15.1, 0.15.2 | torch==2.0.0, torch==2.0.1 |
| 0.14 | 0.14.0, 0.14.1 | torch==1.13.0, torch==1.13.1 |
| 0.13 | 0.13.0, 0.13.1 | torch==1.12.0, torch==1.12.1 |
| 0.12 | 0.12.0 | torch==1.11.0 |
| 0.11 | 0.11.1, 0.11.2, 0.11.3 | torch==1.10.0, torch==1.10.1, torch==1.10.2 |
| 0.10 | 0.10.0, 0.10.1 | torch==1.9.0, torch==1.9.1 |
| 0.9 | 0.9.0, 0.9.1 | torch==1.8.0, torch==1.8.1 |
| 0.8 | 0.8.0, 0.8.1, 0.8.2 | torch==1.7.0, torch==1.7.1 |
| 0.7 | 0.7.0 | torch==1.6.0 |
| 0.6 | 0.6.0, 0.6.1 | torch==1.5.0, torch==1.5.1 |
| 0.5 | 0.5.0 | torch==1.4.0 |
| 0.4 | 0.4.0, 0.4.1, 0.4.2 | torch==1.2.0, torch==1.3.0, torch==1.3.1 |
| 0.3 | 0.3.0 | torch>=1.1.0 |
To pin both, write the pair from the table, for example pip install "torch==2.1.2" "torchvision==0.16.2".
How was this read, and how was it checked?
From the Python files of the first release of every minor on PyPI, plus the latest, read from the Linux x86_64 wheels by HTTP range requests and parsed with Python's ast module. The wheels and the git tags of pytorch/vision agree except for the generated version.py and the prototype package noted above. A module's names are everything it binds at module level and what from .x import * brings in. From 0.26.0, torchvision/io/__init__.py imports the video API from pytorch.vision.fb, a Meta-internal package, inside try: ... except ImportError: pass; that package is not on PyPI, so those names are counted as absent, and torchvision.io.video from 0.28.0, which imports it unconditionally, is counted as not importable.
Checks: (1) the top-level names are found as plain text in torchvision/__init__.py in every release of their range (652 name-and-release pairs) and are not bound on either side (20 edges). (2) A regular expression finds 14,932 definitions in 1,706 file versions; all are among the names read. (3) 19 release checks against the wheels by plain-text search agree:
| Module or name | Release | Wheel and data |
|---|---|---|
torchvision.transforms.functional_tensor | 0.16.0 | has it |
torchvision.transforms.functional_tensor | 0.17.0 | does not |
torchvision.models.utils.load_state_dict_from_url | 0.10.0 | has it |
torchvision.models.utils.load_state_dict_from_url | 0.11.1 | does not |
torchvision.io.read_video | 0.25.0 | has it |
torchvision.io.read_video | 0.26.0 | does not |
torchvision.io.VideoReader | 0.25.0 | has it |
torchvision.io.video | 0.28.0 | does not |
torchvision.datapoints | 0.15.1 | has it |
torchvision.datapoints | 0.16.0 | does not |
torchvision.tv_tensors | 0.16.0 | has it |
torchvision.models.ResNet50_Weights | 0.12.0 | does not |
torchvision.models.ResNet50_Weights | 0.13.0 | has it |
torchvision.transforms.v2 | 0.14.0 | does not |
torchvision.transforms.v2 | 0.15.1 | has it |
torchvision.transforms.functional.rgb_to_grayscale | 0.7.0 | does not |
torchvision.transforms.functional.rgb_to_grayscale | 0.8.0 | has it |
torchvision.transforms.Scale | 0.11.1 | has it |
torchvision.transforms.Scale | 0.12.0 | does not |
Limits
- Nothing was installed or run. "Has it" means the import statement resolves in the Python files of the wheel; an operator that needs the compiled extension (
torchvision.ops.nmson a build without it) can still fail at call time. - The ranges use the first release of each minor version. Every release was also read once (51 releases, from the Python files of one Linux or macOS x86_64 wheel each, with the same rules): 5 top-level names and 1,392 module-and-name pairs in all differ in some patch release from the first release of their minor. The lookup prints those patch releases under the range. torchvision before 0.3.0 is not covered.
Questions
How do I fix "No module named 'torchvision.transforms.functional_tensor'" (basicsr, Real-ESRGAN, GFPGAN)?
torchvision 0.17.0 (2024-01-30) removed the module; 0.16.x warned that it would. basicsr 1.4.2, the latest basicsr on PyPI (2022), still has from torchvision.transforms.functional_tensor import rgb_to_grayscale in basicsr/data/degradations.py, line 8; Real-ESRGAN 0.3.0 and GFPGAN 1.3.8 require basicsr>=1.4.2. Change that line to from torchvision.transforms.functional import rgb_to_grayscale (for a tensor it calls the same code), or pin torchvision<0.17 (0.16.2 needs torch 2.1.2).
How do I fix "cannot import name 'read_video' from 'torchvision.io'"?
torchvision 0.26.0 (2026-03-23) removed video decoding: read_video, read_video_timestamps, write_video and VideoReader are gone from torchvision.io, and so are the modules torchvision.io.video and torchvision.io.video_reader. From 0.28.0 the wheel has a torchvision/io/video.py again, but it imports a Meta-internal package and fails. Use TorchCodec (pip install torchcodec; from torchcodec.decoders import VideoDecoder), or pin torchvision<0.26 (0.25.0 needs torch 2.10.0). Image decoding (read_image, decode_jpeg) is still there.
How do I fix "No module named 'torchvision.models.utils'"?
torchvision 0.11 (2021-10-21) removed it; 0.10.1 is the last release with it. Its one useful name was load_state_dict_from_url: use from torch.hub import load_state_dict_from_url.
Which torchvision version goes with my torch?
Each torchvision wheel on PyPI pins one torch release exactly: torchvision 0.16.2 requires torch==2.1.2, 0.25.0 requires torch==2.10.0. pip install torchvision without a version can therefore up- or downgrade torch. From 0.29.1 the pin is torch>=2.14.0. The table on this page lists every release.
Where did torchvision.datapoints go?
torchvision 0.16.0 (2023-10-04) renamed it torchvision.tv_tensors, and renamed a few v2 transforms (ToImageTensor to ToImage, ConvertDtype to ToDtype, ClampBoundingBox to ClampBoundingBoxes, SanitizeBoundingBox to SanitizeBoundingBoxes).
Sources
- The torchvision wheels on PyPI (file names and sha256 in the build notes), which also give the release dates and the torch requirements.
- pytorch/vision: transforms/functional_tensor.py at v0.16.0 (the removal warning), io/video.py at v0.25.0 (the TorchCodec notice), io/__init__.py at v0.26.0.
- basicsr 1.4.2 on PyPI (basicsr/data/degradations.py in the sdist) and pytorch/torchcodec.
The same data as JSON: torchvision.json, licensed CC BY 4.0.
Related: "No module named 'triton.ops'" · "... from 'flash_attn'" · "... from 'transformers'" · "... from 'timm.models.layers'".