我正在努力遵循本指南https://pythontips.com/2016/02/25/ocr-on-pdf-files-using-python/#comments尝试为朋友制作一些东西并获得练习。
我在使用ImageMagick时遇到了麻烦,这是我的回溯
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 180, in <module>
libraries = load_library()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 135, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Kunbargi/Documents/Untitled.py", line 1, in <module>
from wand.image import Image
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 206, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 180, in <module>
libraries = load_library()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 135, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Kunbargi/Documents/Untitled.py", line 1, in <module>
from wand.image import Image
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wand/api.py", line 206, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-mac
-------install:
http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-mac
我尝试过关注该链接并通过brew和ports安装它
当我在终端中ports installed
时,我得到以下列表,其中显示已安装ImageMagick(第5行)
The following ports are currently installed:
autoconf @2.69_5 (active)
automake @1.15_1 (active)
bzip2 @1.0.6_0 (active)
db48 @4.8.30_4 (active)
djvulibre @3.5.27_0 (active)
expat @2.2.0_0 (active)
fftw-3 @3.3.5_0 (active)
fontconfig @2.12.1_1 (active)
freetype @2.7.1_0 (active)
gdbm @1.13_1 (active)
gettext @0.19.8.1_0 (active)
ghostscript @9.19_0+x11 (active)
giflib @4.2.3_0+x11 (active)
ilmbase @2.2.0_0 (active)
ImageMagick @6.9.8-3_0+x11 (active)
jbig2dec @0.13_0 (active)
jbigkit @2.1_0 (active)
jpeg @9b_0 (active)
lcms2 @2.8_0 (active)
libedit @20160903-3.1_1 (active)
libiconv @1.15_0 (active)
libidn @1.33_0 (active)
libpaper @1.1.24.4_0 (active)
libpng @1.6.29_0 (active)
libtool @2.4.6_2 (active)
libxml2 @2.9.4_0 (active)
ncurses @6.0_0 (active)
openexr @2.2.0_1 (active)
openjpeg @2.1.2_0 (active)
openssl @1.0.2k_0 (active)
perl5 @5.24.1_0+perl5_24 (active)
perl5.24 @5.24.1_0 (active)
pkgconfig @0.29.2_0 (active)
python2_select @0.0_2 (active)
python27 @2.7.13_0 (active)
python_select @0.3_7 (active)
readline @6.3.003_1 (active)
sqlite3 @3.18.0_0 (active)
tiff @4.0.7_0 (active)
urw-fonts @1.0.7pre44_0 (active)
webp @0.6.0_0 (active)
xorg-kbproto @1.0.7_0 (active)
xorg-libice @1.0.9_0 (active)
xorg-libpthread-stubs @0.3_0 (active)
xorg-libsm @1.2.2_0 (active)
xorg-libX11 @1.6.4_0 (active)
xorg-libXau @1.0.8_0 (active)
xorg-libxcb @1.12_2+python27 (active)
xorg-libXdmcp @1.1.2_0 (active)
xorg-libXext @1.3.3_0 (active)
xorg-libXt @1.1.5_1 (active)
xorg-xcb-proto @1.12_1+python27 (active)
xorg-xextproto @7.3.0_0 (active)
xorg-xproto @7.0.31_0 (active)
xz @5.2.3_0 (active)
zlib @1.2.11_0 (active)
并在python返回中执行help('modules')
此列表显示pyocr, pytesseract, wand
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
Cython _tkinter heapq sched
OleFileIO_PL _tracemalloc hmac secrets
PIL _warnings html select
Tesseract _weakref http selectors
Untitled _weakrefset idlelib setuptools
__future__ abc imaplib shelve
_ast aifc imghdr shlex
_asyncio antigravity imp shutil
_bisect argparse importlib signal
_blake2 array inspect site
_bootlocale ast io six
_bz2 asynchat ipaddress smtpd
_codecs asyncio itertools smtplib
_codecs_cn asyncore json sndhdr
_codecs_hk atexit keyword socket
_codecs_iso2022 audioop lib2to3 socketserver
_codecs_jp base64 linecache sqlite3
_codecs_kr bdb locale sre_compile
_codecs_tw binascii logging sre_constants
_collections binhex lzma sre_parse
_collections_abc bisect macpath ssl
_compat_pickle builtins macurl2path stat
_compression bz2 magickwand statistics
_crypt cProfile mailbox string
_csv calendar mailcap stringprep
_ctypes cgi marshal struct
_ctypes_test cgitb math subprocess
_curses chunk mimetypes sunau
_curses_panel cmath mmap symbol
_datetime cmd modulefinder symtable
_dbm code multiprocessing sys
_decimal codecs netrc sysconfig
_dummy_thread codeop nis syslog
_elementtree collections nntplib tabnanny
_functools colorsys ntpath tarfile
_hashlib compileall nturl2path telnetlib
_heapq concurrent numbers tempfile
_imp configparser olefile termios
_io contextlib opcode test
_json copy operator textwrap
_locale copyreg optparse this
_lsprof crypt os threading
_lzma csv parser time
_markupbase ctypes pathlib timeit
_md5 curses pdb tkinter
_multibytecodec cython pickle token
_multiprocessing datetime pickletools tokenize
_opcode dbm pip trace
_operator decimal pipes traceback
_osx_support difflib pkg_resources tracemalloc
_pickle dis pkgutil tty
_posixsubprocess distutils platform turtle
_pydecimal doctest plistlib turtledemo
_pyio dummy_threading poplib types
_random easy_install posix typing
_scproxy email posixpath unicodedata
_sha1 encodings pprint unittest
_sha256 ensurepip profile urllib
_sha3 enum pstats uu
_sha512 errno pty uuid
_signal faulthandler pwd venv
_sitebuiltins fcntl py_compile wand
_socket filecmp pyclbr warnings
_sqlite3 fileinput pydoc wave
_sre fnmatch pydoc_data weakref
_ssl formatter pyexpat webbrowser
_stat fractions pyocr wsgiref
_string ftplib pytesseract xdrlib
_strptime functools pyximport xml
_struct gc queue xmlrpc
_symtable genericpath quopri xxlimited
_sysconfigdata_m_darwin_darwin getopt random xxsubtype
_testbuffer getpass re zipapp
_testcapi gettext readline zipfile
_testimportmultiple glob reprlib zipimport
_testmultiphase grp resource zlib
_thread gzip rlcompleter
_threading_local hashlib runpy