环境还是Ubuntu 22.04, 系统自带的python是3.10.6。 在安装tesserocr库时报如下错误,这里只截取有用的部分。
cj@vm-ubuntu:~$ pip install tesserocr pillow
Defaulting to user installation because normal site-packages is not writeable
Collecting tesserocr
Using cached tesserocr-2.6.0.tar.gz (58 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [114 lines of output]
Supporting tesseract v4.1.1
Tesseract major version 4
Building with configs: {'libraries': ['tesseract', 'lept'], 'compile_time_env': {'TESSERACT_MAJOR_VERSION': 4, 'TESSERACT_VERSION': 67174656}}
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
warnings.warn(
/usr/lib/python3/dist-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
warnings.warn(
ERROR: Exception:
Traceback (most recent call last):
用系统装了一下午的环境都没有问题,唯独安装这个库时报错了。直接导致我的方向错误,以为又是库的兼容问题。到头来原来只是pip版本太低导致的,其实从错误信息里已经可以猜到。当然马后炮比较容易,当时还是挺抓狂的。解决方法简单,升级pip版本。
cj@vm-ubuntu:~$ python3 -m pip install --upgrade pip
升级完成后再安装就成功了。
cj@vm-ubuntu:~$ pip install tesserocr pillow
Defaulting to user installation because normal site-packages is not writeable
Collecting tesserocr
Using cached tesserocr-2.6.0.tar.gz (58 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (9.0.1)
Building wheels for collected packages: tesserocr
Building wheel for tesserocr (setup.py) ... done
Created wheel for tesserocr: filename=tesserocr-2.6.0-cp310-cp310-linux_x86_64.whl size=702532 sha256=e8d5bcf12bd804e99d65b3d84611d719292ed0919f4f9f22f70365f12a5a65e5
Stored in directory: /home/cj/.cache/pip/wheels/d3/32/70/cc42f7bdba1628b48893b538f1cbf72154fba51d738df5531d
Successfully built tesserocr
Installing collected packages: tesserocr
Successfully installed tesserocr-2.6.0