python版本3.8
代码如下[Python] 纯文本查看 复制代码 from PIL import Image
import pytesseract
text = pytesseract.image_to_string(Image.open(r'C:\Users\96538\Desktop\1.png'),lang='chi_sim')
print(text)
运行报错内容如下
[Asm] 纯文本查看 复制代码 Traceback (most recent call last):
File "d:/VSCodePython/OCR识别/test.py", line 2, in <module>
import pytesseract
ModuleNotFoundError: No module named 'pytesseract'
尝试使用[Python] 纯文本查看 复制代码 pip install pytesseract 命令重新安装
提示内容如下
[Asm] 纯文本查看 复制代码 Requirement already satisfied: pytesseract in d:\miniconda3\lib\site-packages (0.3.9)
Requirement already satisfied: packaging>=21.3 in d:\miniconda3\lib\site-packages (from pytesseract) (21.3)
Requirement already satisfied: Pillow>=8.0.0 in d:\miniconda3\lib\site-packages (from pytesseract) (9.0.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in d:\miniconda3\lib\site-packages (from packaging>=21.3->pytesseract) (3.0.7)
后面尝试使用[Asm] 纯文本查看 复制代码 conda install pytesseract
提示内容如下
[Asm] 纯文本查看 复制代码 Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- pytesseract
Current channels:
- [url]https://repo.anaconda.com/pkgs/main/win-64[/url]
- [url]https://repo.anaconda.com/pkgs/main/noarch[/url]
- [url]https://repo.anaconda.com/pkgs/r/win-64[/url]
- [url]https://repo.anaconda.com/pkgs/r/noarch[/url]
- [url]https://repo.anaconda.com/pkgs/msys2/win-64[/url]
- [url]https://repo.anaconda.com/pkgs/msys2/noarch[/url]
To search for alternate channels that may provide the conda package you're
looking for, navigate to
[url]https://anaconda.org[/url]
and use the search bar at the top of the page.
使用powerShell可以正常运行输出结果
[Asm] 纯文本查看 复制代码 PS C:\Users\96538\Desktop> python
Python 3.8.1 (default, Mar 2 2020, 13:06:26) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> import pytesseract
>>> text = pytesseract.image_to_string(Image.open(r'C:\Users\96538\Desktop\1.png'),lang='chi_sim')
>>> print(text) |