【问题标题】:python import : ModuleNotFoundError: No module named 'pytesser'python导入:ModuleNotFoundError:没有名为“pytesser”的模块
【发布时间】:2019-06-27 14:14:34
【问题描述】:

您好,我是 python 和 OCR 的新手。我正在尝试实施 OCR。我已经安装了 OCR 所需的所有依赖项。同样重要的是我使用的是 Anaconda custom 提供的 Python。因此,当我尝试导入 pytesser 时,它会显示 ModuleNotFoundError: No module named 'pytesser'。我正在尝试执行一个简单的以下程序:

import sys
print (sys.path)
from PIL import Image
from pytesser import *

image_file = 'imageSample1.jpg'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print ("=====output=======\n")
print (text)

得到以下输出:

nilkash@nilkash:~/ubuntuBackup/My_Folder/Its_my_work/DS/ML&AI/ImageRecognition$ python SampleImageContentRecognition.py 
['/home/nilkash/ubuntuBackup/My_Folder/Its_my_work/DS/ML&AI/ImageRecognition', '/home/nilkash/anaconda3/lib/python36.zip', '/home/nilkash/anaconda3/lib/python3.6', '/home/nilkash/anaconda3/lib/python3.6/lib-dynload', '/home/nilkash/anaconda3/lib/python3.6/site-packages', '/home/nilkash/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.6-py3.6.egg', '/home/nilkash/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg']
Traceback (most recent call last):
  File "SampleImageContentRecognition.py", line 4, in <module>
    from pytesser import *
ModuleNotFoundError: No module named 'pytesser'

我相信因为 python 的 conda 发行版它不能使用它。有什么方法可以链接。或者我做错了什么。需要一些帮助。谢谢。

我深入研究了这个问题。我安装了两个python版本,一个是python2.7,另一个是python3.6。所以我所有的pytesseract配置都是用python2.7。但我使用的是 3.6 版。所以我认为我需要做的是删除所有 pytesseract 并针对 python3.6 安装。否则将所有配置移至python3.6。我尝试通过conda install -c auto pytesseract conda 版本的 pytesseract 但收到以下错误:

UnsatisfiableError: The following specifications were found to be in conflict:
  - pytesseract -> python 2.7*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

有没有办法解决这个问题。需要一些帮助。

【问题讨论】:

  • 您是否确认您使用 Anaconda Python 实例安装了所有依赖项?或者您是否安装了多个 Python 实例,并且可能将您的依赖项安装到另一个实例中?

标签: python anaconda ocr pytesser


【解决方案1】:

你应该可以在你的 anaconda 提示符中使用 PIP Using Pip to install packages to Anaconda Environment

打开 anaconda 命令行提示符并使用 pip 安装您的软件包

pip install pytesseract

【讨论】:

  • Thomas 感谢您的快速重播。我试图在 conda 的特定环境中安装 pytesseract。我用以下方式尝试过:conda install -n root pytesseract 但它说PackageNotFoundError: Packages missing in current channels: - pytesseract。有没有其他方法可以在 conda env 中安装?
  • 是的,我用 pip 试过了,上面写着Requirement already satisfied: pytesseract in ./anaconda3/lib/python3.6/site-packages
  • 但在同一个终端中,如果我尝试导入它,它会显示ModuleNotFoundError: No module named 'pytesser'
【解决方案2】:

看起来他们不在同一路径下,python找不到它。

请参考此链接:

How to reset System Variable PATH after tesseract installation

【讨论】:

    猜你喜欢
    • 2020-03-11
    • 1970-01-01
    • 2021-05-16
    • 2019-04-12
    • 2021-04-02
    • 2020-02-25
    • 2021-12-14
    • 2022-01-07
    • 1970-01-01
    相关资源
    最近更新 更多