mmocr: ModuleNotFoundError: No module named 'mmcv._ext'

I tried all possible way explained in this thread. Still i am getting same error. Here are specs i am working on: OS: Windows 10 ±----------------------------------------------------------------------------+ | NVIDIA-SMI 496.49 Driver Version: 496.49 CUDA Version: 11.5 | |-------------------------------±---------------------±---------------------+

Torch-1.11.0+cu115 torch.cuda.is_available()) - True Torchvision - 0.12.0+cu115 mmdet.version - 2.22.0

ModuleNotFoundError: No module named 'mmcv._ext'

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16

Most upvoted comments

Thanks for the detailed log. It’s probably because of the wrongly cached mmcv-full

Collecting mmcv-full
  Using cached mmcv_full-1.4.6-py2.py3-none-any.whl

Make sure you have cleared the cache before installing mmcv-full:

pip cache dir  # to get the path to the pip cache
rmdir PATH_TO_PIP_CACHE
pip uninstall mmcv-full
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html

Seems like a scipy’s feature that imports MMOCR twice. You can try disabling it https://stackoverflow.com/questions/46485628/avoid-reloaded-modules-module-name-message-in-python

Creating Conda environment conda create -n open-mmlab python=3.7 -y conda activate open-mmlab

Installing pytorch and torchvision pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html After this installing mmcv-full pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html

pip install mmdet

cd mmocr pip install -r requirements.txt

pip install -v -e .

After this running script in spyder

# Check Pytorch installation
import torch, torchvision
print(torch.__version__, torch.cuda.is_available())

#print(torch.__version__)
print(torchvision.__version__)
# Check MMDetection installation
import mmdet
print(mmdet.__version__)

# Check mmcv installation
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print(mmcv.__version__)
print(get_compiling_cuda_version())
print(get_compiler_version())

# Check mmocr installation
import mmocr
print(mmocr.__version__)

Output

Python 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.31.1 -- An enhanced Interactive Python.

runfile('C:/Users/Nirbhay/.spyder-py3/temp.py', wdir='C:/Users/Nirbhay/.spyder-py3')
1.10.0+cu113 True
0.11.0+cu113
2.22.0
Traceback (most recent call last):

  File "C:\Users\Nirbhay\.spyder-py3\temp.py", line 13, in <module>
    from mmcv.ops import get_compiling_cuda_version, get_compiler_version

  File "C:\Users\Nirbhay\anaconda3\envs\open-mmlab\lib\site-packages\mmcv\ops\__init__.py", line 2, in <module>
    from .active_rotated_filter import active_rotated_filter

  File "C:\Users\Nirbhay\anaconda3\envs\open-mmlab\lib\site-packages\mmcv\ops\active_rotated_filter.py", line 10, in <module>
    ['active_rotated_filter_forward', 'active_rotated_filter_backward'])

  File "C:\Users\Nirbhay\anaconda3\envs\open-mmlab\lib\site-packages\mmcv\utils\ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)

  File "C:\Users\Nirbhay\anaconda3\envs\open-mmlab\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

ModuleNotFoundError: No module named 'mmcv._ext'

Please uninstall mmcv and install mmcv-full following the installation instructions