mmocr
mmocr copied to clipboard
Failed to build lanms-neo while installing MMOCR
I tried installing mmocr in every possible but I get this error stating that
ERROR: Failed building wheel for lanms-neo
Failed to build lanms-neo
ERROR: Could not build wheels for lanms-neo, which is required to install pyproject.toml-based projects
When I install it in google colab its working but not in my windows system.
Here's the error log for your reference
Building wheels for collected packages: lanms-neo
Building wheel for lanms-neo (pyproject.toml) ... error
ERROR: Command errored out with exit status 1:
command: 'E:\PycharmProjects\table_extraction\venv\Scripts\python.exe' 'E:\PycharmProjects\table_extraction\venv\lib\site-packages\pip\_vendor\pep517\in
_process\_in_process.py' build_wheel 'C:\Users\arhams\AppData\Local\Temp\tmpv2818r8b'
cwd: C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6
Complete output (26 lines):
running bdist_wheel
running build
running build_py
running build_ext
building 'lanms._C' extension
clipper.cpp
lanms.cpp
C:\Users\arhams\AppData\Local\Temp\pip-build-env-sq3_aurr\overlay\Lib\site-packages\pybind11\include\pybind11\detail/common.h(1040): error C2737: 'pybind
11::overload_cast': 'constexpr' object must be initialized
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(18): warning C4244: '+=': conversio
n from 'double' to 'float', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(66): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(67): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(69): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(70): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(72): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(73): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(75): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(76): warning C4244: '+=': conversio
n from 'float' to 'int64_t', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(147): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(148): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(149): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(150): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(151): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(152): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(153): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
C:\Users\arhams\AppData\Local\Temp\pip-install-1j6n0n8m\lanms-neo_1a6c5c149ebf454abc3e832883cdaab6\lanms\csrc\lanms.h(154): warning C4244: '=': conversio
n from 'float' to 'ClipperLib::cInt', possible loss of data
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed wit
h exit code 2
----------------------------------------
ERROR: Failed building wheel for lanms-neo
Failed to build lanms-neo
ERROR: Could not build wheels for lanms-neo, which is required to install pyproject.toml-based projects
Could you try upgrading your MSVC to 19.xx? Our local compilation succeeded at this version.
Can you guide me how I could upgrade it as I can't get it what you are trying to say. My Microsoft Visual C++ distribution is of version 14.xx
Sorry for the confusion, I'm not an expert on Windows. 19.xx is the version of MSVC compiler instead of MSVC. Our unit test shows that the compilation succeeded at Windows 2022. According to the specs (https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md), you might try to upgrade your MSVC to 14.32.31332 for a successful compilation.
Thanks It is working but while running the program, I get another error! Which is mentioned below:-
Traceback (most recent call last):
File "E:/PycharmProjects/table_extraction/api.py", line 6, in <module>
from mmocr.datasets.pipelines.crop import crop_img
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmocr\datasets\__init__.py", line 2, in <module>
from mmdet.datasets.builder import DATASETS, build_dataloader, build_dataset
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\datasets\__init__.py", line 2, in <module>
from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\datasets\builder.py", line 15, in <module>
from .samplers import (ClassAwareSampler, DistributedGroupSampler,
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\datasets\samplers\__init__.py", line 2, in <module>
from .class_aware_sampler import ClassAwareSampler
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\datasets\samplers\class_aware_sampler.py", line 8, in <module>
from mmdet.core.utils import sync_random_seed
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\core\__init__.py", line 3, in <module>
from .bbox import * # noqa: F401, F403
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\core\bbox\__init__.py", line 8, in <module>
from .samplers import (BaseSampler, CombinedSampler,
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\core\bbox\samplers\__init__.py", line 12, in <module>
from .score_hlr_sampler import ScoreHLRSampler
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmdet\core\bbox\samplers\score_hlr_sampler.py", line 3, in <module>
from mmcv.ops import nms_match
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\ops\__init__.py", line 2, in <module>
from .active_rotated_filter import active_rotated_filter
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\ops\active_rotated_filter.py", line 10, in <module>
ext_module = ext_loader.load_ext(
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\utils\ext_loader.py", line 13, in load_ext
ext = importlib.import_module('mmcv.' + name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing _ext: The specified procedure could not be found.
It's because mmcv-full
hasn't been installed correctly. Try the following commands:
pip uninstall mmcv-full
pip uninstall mmcv
pip install -U openmim
mim install mmcv-full
which should address your issue.
Thanks I have installed the mmcv-full package and it's working but while executing my program, I am getting an error which is related to installation I guess
import cv2
from mmocr.utils.ocr import MMOCR
# Initiating text detection engine
det_engine = MMOCR(det='TextSnake', recog=None)
path = 'E:\PycharmProjects\template.png'
# Inference and displaying detected text
img = cv2.imread(path)
results = det_engine.readtext(img, output='det_out.jpg', details=True)
cv2.imshow(cv2.imread("det_out.jpg"))
Error Log:
Traceback (most recent call last):
File "E:/PycharmProjects/table_extraction/api.py", line 11, in <module>
det_engine = MMOCR(det='TextSnake', recog=None)
File "E:\PycharmProjects\table_extraction\mmocr\mmocr\utils\ocr.py", line 394, in __init__
self.detect_model = init_detector(
File "E:\PycharmProjects\table_extraction\mmocr\mmocr\apis\inference.py", line 34, in init_detector
config = mmcv.Config.fromfile(config)
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\utils\config.py", line 340, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename,
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\utils\config.py", line 183, in _file2dict
check_file_exist(filename)
File "E:\PycharmProjects\table_extraction\venv\lib\site-packages\mmcv\utils\path.py", line 23, in check_file_exist
raise FileNotFoundError(msg_tmpl.format(filename))
FileNotFoundError: file "E:\PycharmProjects\table_extraction\configs\textdet\textsnake\textsnake_r50_fpn_unet_1200e_ctw1500.py" does not exist
If you installed mmocr
as a pip package, then you should prepare the configs and checkpoints following https://mmocr.readthedocs.io/en/latest/install.html#case-b-installed-as-a-package
Thank you @gaotongxiao, the issue has been resolved!