首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pytesser出现导入错误

pytesser出现导入错误
EN

Stack Overflow用户
提问于 2016-08-13 12:59:19
回答 1查看 2K关注 0票数 2

我正在尝试用python实现OCR。当我运行以下代码时:

代码语言:javascript
复制
from PIL import Image
from pytesser import *

image_file = 'menu.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

我得到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
 File "C:/Python27/ocr.py", line 2, in <module>
    from pytesser import *
  File "C:/Python27\pytesser.py", line 6, in <module>
ImportError: No module named Image

我在我的C:\Python27\Lib\site-packages目录中有一个名为pytesser的文件夹,在安装PILLOW的同一目录中还有一个名为PIL的文件夹。

编辑:我在Why can't Python import Image from PIL?上尝试了这个解决方案。但这似乎没什么帮助

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-13 13:15:22

根据回溯,错误不是来自c:\Python27\Lib\Site-Packages中的pytesser,而是来自C:\Python27\pytesser.py line 6

你能分享一下C:\Python27\pytesser.py第6行的代码吗?或者通过查看C:\Python27\pytesser.py line 6上的代码来调试它

如果您希望ocr.py使用C:\Python27\Lib\site-packages中的pytesser (如果存在),请从ocr.py目录中删除pytesser

如果它是您自己编写的,理想情况下应该是from PIL import Image,而不是import Image

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38929372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档