IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Centos 7 安装PyMuPDF

    obaby发表于 2024-08-21 02:38:34
    love 0

    接引前文,昨天把代码写好测试 ok 之后,以为就万事大吉了。然而,今天往服务器上部署的时候,直接给整麻了。问题一个接一个,错误一堆接一堆。直接让人破防了。

    对于 linux 的发行版,我并没有神马偏见,主要是用过的版本也不多,但是,不得不说那个 centos 是真烂,也不知道为啥那么多人喜欢用这个破系统。

    直接 pip 安装,好嘛,这一堆错误:

    [root@iZbp12k4fwg2euy5kkr9u7Z ~]# pip install PyMuPDF
    Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
    Collecting PyMuPDF
      Using cached http://mirrors.cloud.aliyuncs.com/pypi/packages/9f/1d/032d24e0c774e67742395fda163a172c60e4d0f9875785d5199eb2956d5e/PyMuPDF-1.19.6.tar.gz (2.3 MB)
      Preparing metadata (setup.py) ... done
    Using legacy 'setup.py install' for PyMuPDF, since package 'wheel' is not installed.
    Installing collected packages: PyMuPDF
        Running setup.py install for PyMuPDF ... error
        ERROR: Command errored out with exit status 1:
         command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8aqc9a1k/pymupdf_d5ebd12caf9445ab82d6a5af68229d72/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8aqc9a1k/pymupdf_d5ebd12caf9445ab82d6a5af68229d72/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7fhkepkr/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/PyMuPDF
             cwd: /tmp/pip-install-8aqc9a1k/pymupdf_d5ebd12caf9445ab82d6a5af68229d72/
        Complete output (20 lines):
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-3.6
        creating build/lib.linux-x86_64-3.6/fitz
        copying fitz/__init__.py -> build/lib.linux-x86_64-3.6/fitz
        copying fitz/fitz.py -> build/lib.linux-x86_64-3.6/fitz
        copying fitz/utils.py -> build/lib.linux-x86_64-3.6/fitz
        copying fitz/__main__.py -> build/lib.linux-x86_64-3.6/fitz
        running build_ext
        building 'fitz._fitz' extension
        creating build/temp.linux-x86_64-3.6
        creating build/temp.linux-x86_64-3.6/fitz
        gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/freetype2 -I/usr/include/python3.6m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.6/fitz/fitz_wrap.o
        fitz/fitz_wrap.c:2755:18: fatal error: fitz.h: No such file or directory
         #include <fitz.h>
                          ^
        compilation terminated.
        error: command 'gcc' failed with exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8aqc9a1k/pymupdf_d5ebd12caf9445ab82d6a5af68229d72/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8aqc9a1k/pymupdf_d5ebd12caf9445ab82d6a5af68229d72/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7fhkepkr/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/PyMuPDF Check the logs for full command output.

    按照提示看来是 gcc 报错了,错误原因是没有头文件,一通搜索:https://blog.csdn.net/u012140499/article/details/112798704 提供了解决思路,下载源码https://casper.mupdf.com/releases/安装。

    直接下载最新版编译,又是一堆报错:

    source/fitz/util.c: In function ‘fz_new_xhtml_document_from_document’:
    source/fitz/util.c:866:2: warning: ‘new_doc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      return new_doc;
      ^
        CC build/release/source/fitz/warp.o
        CC build/release/source/fitz/writer.o
    source/fitz/writer.c: In function ‘fz_new_document_writer_with_buffer’:
    source/fitz/writer.c:305:2: warning: ‘wri’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      return wri;
      ^
        CC build/release/source/fitz/xml.o
        CC build/release/source/fitz/xmltext-device.o
        CC build/release/source/fitz/zip.o
        CXX build/release/source/fitz/tessocr.o
    /bin/sh: g++: command not found
    make: *** [build/release/source/fitz/tessocr.o] Error 127

    提示找不到 g++,嗯,再来解决 g++

    yum search "gcc-c++"

    就一个结果:

    oaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.cloud.aliyuncs.com
     * extras: mirrors.cloud.aliyuncs.com
     * updates: mirrors.cloud.aliyuncs.com
    ======================================================================================================= N/S matched: gcc-c++ =======================================================================================================
    gcc-c++.x86_64 : C++ support for GCC
    
      Name and summary matches only, use "search all" for everything.

    安装 g++:

    [root@iZbp12k4fwg2euy5kkr9u7Z mupdf-1.22.0-source]# yum install "gcc-c++.x86_64" -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.cloud.aliyuncs.com
     * extras: mirrors.cloud.aliyuncs.com
     * updates: mirrors.cloud.aliyuncs.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package gcc-c++.x86_64 0:4.8.5-44.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================================================================================================================================================
     Package                                                Arch                                                  Version                                                     Repository                                           Size
    ====================================================================================================================================================================================================================================
    Installing:
     gcc-c++                                                x86_64                                                4.8.5-44.el7                                                base                                                7.2 M
    
    Transaction Summary
    ====================================================================================================================================================================================================================================
    Install  1 Package
    
    Total download size: 7.2 M
    Installed size: 16 M
    Downloading packages:
    gcc-c++-4.8.5-44.el7.x86_64.rpm                                                                                                                                                                              | 7.2 MB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : gcc-c++-4.8.5-44.el7.x86_64                                                                                                                                                                                      1/1 
      Verifying  : gcc-c++-4.8.5-44.el7.x86_64                                                                                                                                                                                      1/1 
    
    Installed:
      gcc-c++.x86_64 0:4.8.5-44.el7                                                                                                                                                                                                     
    
    Complete!
    

    再来一遍:

    make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install

    编译安装命令参考这个链接:https://mupdf.readthedocs.io/en/latest/quick-start-guide.html#linux

    几百行错误出来了:

    thirdparty/harfbuzz/src/graph/../hb-meta.hh:76:41: note: in definition of macro ‘HB_AUTO_RETURN’
     #define HB_AUTO_RETURN(E) -> decltype ((E)) { return (E); }
                                             ^
    In file included from thirdparty/harfbuzz/src/graph/pairpos-graph.hh:32:0,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:31,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:
    thirdparty/harfbuzz/src/graph/classdef-graph.hh: In constructor ‘graph::class_def_size_estimator_t::class_def_size_estimator_t(It)’:
    thirdparty/harfbuzz/src/graph/classdef-graph.hh:155:44: error: ‘struct hb_hashmap_t<unsigned int, hb_set_t>’ has no member named ‘keys’
         for (unsigned klass : glyphs_per_class.keys ())
                                                ^
    thirdparty/harfbuzz/src/graph/classdef-graph.hh: In member function ‘bool graph::class_def_size_estimator_t::in_error()’:
    thirdparty/harfbuzz/src/graph/classdef-graph.hh:200:47: error: ‘struct hb_hashmap_t<unsigned int, hb_set_t>’ has no member named ‘values’
         for (const hb_set_t& s : glyphs_per_class.values ())
                                                   ^
    In file included from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:0:
    thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh: In member function ‘void graph::Lookup::fix_existing_subtable_links(graph::gsubgpos_graph_context_t&, unsigned int, hb_vector_t<hb_pair_t<unsigned int, hb_vector_t<unsigned int> > >&)’:
    thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:259:28: error: ‘struct hb_serialize_context_t::object_t’ has no member named ‘all_links_writer’
           for (auto& l : v.obj.all_links_writer ())
                                ^
    thirdparty/harfbuzz/src/graph/gsubgpos-context.cc: In member function ‘unsigned int graph::gsubgpos_graph_context_t::num_non_ext_subtables()’:
    thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:62:25: error: ‘struct hb_hashmap_t<unsigned int, graph::Lookup*>’ has no member named ‘values’
       for (auto l : lookups.values ())
                             ^
    In file included from thirdparty/harfbuzz/src/graph/../hb.hh:484:0,
                     from thirdparty/harfbuzz/src/graph/../hb-set.hh:31,
                     from thirdparty/harfbuzz/src/graph/graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:
    thirdparty/harfbuzz/src/graph/../hb-vector.hh: In instantiation of ‘Type hb_vector_t<Type, sorted>::pop() [with Type = hb_user_data_array_t::hb_user_data_item_t; bool sorted = false]’:
    thirdparty/harfbuzz/src/graph/../hb-object.hh:127:7:   required from ‘void hb_lockable_set_t<item_t, lock_t>::fini(lock_t&) [with item_t = hb_user_data_array_t::hb_user_data_item_t; lock_t = hb_mutex_t]’
    thirdparty/harfbuzz/src/graph/../hb-object.hh:185:34:   required from here
    thirdparty/harfbuzz/src/graph/../hb-vector.hh:398:43: error: cannot convert ‘std::remove_reference<hb_user_data_array_t::hb_user_data_item_t&>::type {aka hb_user_data_array_t::hb_user_data_item_t}’ to ‘hb_user_data_key_t*’ in initialization
         Type v {std::move (arrayZ[length - 1])};
                                               ^
    In file included from thirdparty/harfbuzz/src/graph/../hb.hh:481:0,
                     from thirdparty/harfbuzz/src/graph/../hb-set.hh:31,
                     from thirdparty/harfbuzz/src/graph/graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:
    thirdparty/harfbuzz/src/graph/../hb-iter.hh: In instantiation of ‘void hb_copy(S&&, D&&) [with S = const hb_hashmap_t<unsigned int, unsigned int, true>&; D = hb_hashmap_t<unsigned int, unsigned int, true>&]’:
    thirdparty/harfbuzz/src/graph/../hb-map.hh:46:100:   required from ‘hb_hashmap_t<K, V, minus_one>::hb_hashmap_t(const hb_hashmap_t<K, V, minus_one>&) [with K = unsigned int; V = unsigned int; bool minus_one = true]’
    thirdparty/harfbuzz/src/graph/../hb-map.hh:444:56:   required from here
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:1016:14: error: no match for call to ‘(const<anonymous struct>) (const hb_hashmap_t<unsigned int, unsigned int, true>&)’
       hb_iter (is) | hb_sink (id);
                  ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:156:1: note: candidates are:
     {
     ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:158:3: note: template<class T> hb_iter_type<T><anonymous struct>::operator()(T&&) const
       operator () (T&& c) const
       ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:158:3: note:   template argument deduction/substitution failed:
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:164:3: note: template<class Type> hb_array_t<Type><anonymous struct>::operator()(Type*, unsigned int) const
       operator () (Type *array, unsigned int length) const
       ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:164:3: note:   template argument deduction/substitution failed:
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:1016:14: note:   mismatched types ‘Type*’ and ‘hb_hashmap_t<unsigned int, unsigned int, true>’
       hb_iter (is) | hb_sink (id);
                  ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:168:3: note: template<class Type, unsigned int length> hb_array_t<Type><anonymous struct>::operator()(Type (&)[length]) const
       operator () (Type (&array)[length]) const
       ^
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:168:3: note:   template argument deduction/substitution failed:
    thirdparty/harfbuzz/src/graph/../hb-iter.hh:1016:14: note:   mismatched types ‘Type [length]’ and ‘const hb_hashmap_t<unsigned int, unsigned int, true>’
       hb_iter (is) | hb_sink (id);
                  ^
    In file included from thirdparty/harfbuzz/src/graph/../hb-serialize.hh:36:0,
                     from thirdparty/harfbuzz/src/graph/../hb-machinery.hh:37,
                     from thirdparty/harfbuzz/src/graph/../hb-bit-set.hh:33,
                     from thirdparty/harfbuzz/src/graph/../hb-bit-set-invertible.hh:32,
                     from thirdparty/harfbuzz/src/graph/../hb-set.hh:32,
                     from thirdparty/harfbuzz/src/graph/graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-graph.hh:27,
                     from thirdparty/harfbuzz/src/graph/gsubgpos-context.cc:27:
    thirdparty/harfbuzz/src/graph/../hb-map.hh: In instantiation of ‘uint32_t hb_hashmap_t<K, V, minus_one>::hash() const [with K = unsigned int; V = unsigned int; bool minus_one = true; uint32_t = unsigned int]’:
    thirdparty/harfbuzz/src/graph/../hb-algs.hh:237:43:   required from ‘constexpr hb_head_t<unsigned int, decltype (hb_deref(v).hash())><anonymous struct>::impl(const T&, hb_priority<1u>) const [with T = hb::shared_ptr<hb_map_t>; hb_head_t<unsigned int, decltype (hb_deref(v).hash())> = unsigned int]’
    thirdparty/harfbuzz/src/graph/../hb-algs.hh:245:3:   required by substitution of ‘template<class T> constexpr hb_head_t<unsigned int, decltype (((const<anonymous struct>*)this)-><anonymous struct>::impl(v, hb_priority<16u>()))><anonymous struct>::operator()(const T&) const [with T = hb::shared_ptr<hb_map_t>]’
    thirdparty/harfbuzz/src/graph/../hb-map.hh:257:50:   required from ‘bool hb_hashmap_t<K, V, minus_one>::has(K, VV**) const [with VV = unsigned int; K = hb::shared_ptr<hb_map_t>; V = unsigned int; bool minus_one = false]’
    thirdparty/harfbuzz/src/graph/../hb-ot-layout-common.hh:3034:36:   required from here
    thirdparty/harfbuzz/src/graph/../hb-map.hh:291:19: error: ‘iter_items’ was not declared in this scope
         + iter_items ()
                       ^
    thirdparty/harfbuzz/src/graph/../hb-map.hh: In instantiation of ‘bool hb_hashmap_t<K, V, minus_one>::is_equal(const hb_hashmap_t<K, V, minus_one>&) const [with K = unsigned int; V = unsigned int; bool minus_one = true]’:
    thirdparty/harfbuzz/src/graph/../hb-map.hh:306:78:   required from ‘bool hb_hashmap_t<K, V, minus_one>::operator==(const hb_hashmap_t<K, V, minus_one>&) const [with K = unsigned int; V = unsigned int; bool minus_one = true]’
    thirdparty/harfbuzz/src/graph/../hb-map.hh:96:65:   required from ‘bool hb_hashmap_t<K, V, minus_one>::item_t::operator==(const K&) const [with K = hb::shared_ptr<hb_map_t>; V = unsigned int; bool minus_one = false]’
    thirdparty/harfbuzz/src/graph/../hb-map.hh:258:33:   required from ‘bool hb_hashmap_t<K, V, minus_one>::has(K, VV**) const [with VV = unsigned int; K = hb::shared_ptr<hb_map_t>; V = unsigned int; bool minus_one = false]’
    thirdparty/harfbuzz/src/graph/../hb-ot-layout-common.hh:3034:36:   required from here
    thirdparty/harfbuzz/src/graph/../hb-map.hh:300:28: error: ‘iter’ was not declared in this scope
         for (auto pair : iter ())
                                ^
    make: *** [build/release/thirdparty/harfbuzz/src/graph/gsubgpos-context.o] Error 1

    尝试多个版本都会出现上面的错误,或者会提示不支持 c++17 标准,直接搜索错误多数解决方案都是升级 gcc 编译器,这尼玛,yum 不支持,源码安装又是一堆依赖,我升级,升级你妹。

    尝试降级 mupdf 版本,终于经过多次尝试之后发现1.12 版本是可以安装的。

    install -d /usr/local/include/mupdf
    install -d /usr/local/include/mupdf/fitz
    install -d /usr/local/include/mupdf/pdf
    install include/mupdf/*.h /usr/local/include/mupdf
    install include/mupdf/fitz/*.h /usr/local/include/mupdf/fitz
    install include/mupdf/pdf/*.h /usr/local/include/mupdf/pdf
    install -d /usr/local/lib
    install build/release/libmupdf.a build/release/libmupdfthird.a /usr/local/lib
    install -d /usr/local/bin
    install build/release/mutool    build/release/muraster   build/release/mujstest build/release/mjsgen /usr/local/bin
    install -d /usr/local/share/man/man1
    install docs/man/*.1 /usr/local/share/man/man1
    install -d /usr/local/share/doc/mupdf
    install -d /usr/local/share/doc/mupdf/examples
    install README COPYING CHANGES /usr/local/share/doc/mupdf
    install docs/*.html docs/*.css docs/*.png /usr/local/share/doc/mupdf
    install docs/examples/* /usr/local/share/doc/mupdf/examples

    来继续 pip,来看着几千行的报错,尼玛,你要炸啊:

        fitz/fitz_wrap.c: In function ‘JM_rect_from_py’:
        fitz/fitz_wrap.c:4042:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘util_include_point_in_rect’:
        fitz/fitz_wrap.c:3447:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘util_transform_point’:
        fitz/fitz_wrap.c:3461:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘util_union_rect’:
        fitz/fitz_wrap.c:3468:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘util_concat_matrix’:
        fitz/fitz_wrap.c:3475:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘JM_matrix_from_py’:
        fitz/fitz_wrap.c:4131:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘JM_derotate_page_matrix’:
        fitz/fitz_wrap.c:5193:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        fitz/fitz_wrap.c: In function ‘JM_irect_from_py’:
        fitz/fitz_wrap.c:4071:1: warning: control reaches end of non-void function [-Wreturn-type]
         }
         ^
        error: command 'gcc' failed with exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kfa4_6i0/pymupdf_d444a7b2e89d4aa38ac652587530e9a2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kfa4_6i0/pymupdf_d444a7b2e89d4aa38ac652587530e9a2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-b8m2p6nm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/PyMuPDF Check the logs for full command output.

    尝试降低版本:

    [root@iZbp12k4fwg2euy5kkr9u7Z mupdf-1.12.0-source]# pip install PyMuPDF==1.12
    Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
    ERROR: Could not find a version that satisfies the requirement PyMuPDF==1.12 (from versions: 1.11.2, 1.12.5, 1.13.20, 1.14.19.post2, 1.14.19.2, 1.14.20, 1.14.21, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.16.7, 1.16.8, 1.16.8.1, 1.16.9, 1.16.10, 1.16.11, 1.16.12, 1.16.13, 1.16.14, 1.16.15, 1.16.16, 1.16.17, 1.16.18, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.17.6, 1.17.7, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.18.6, 1.18.7, 1.18.8, 1.18.9, 1.18.10, 1.18.11, 1.18.12, 1.18.13, 1.18.14, 1.18.15, 1.18.16, 1.18.17, 1.18.18, 1.18.19, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.19.6)
    ERROR: No matching distribution found for PyMuPDF==1.12

    提示没有 1.12,那就1.12.5:

    [root@iZbp12k4fwg2euy5kkr9u7Z mupdf-1.12.0-source]# pip install PyMuPDF==1.12.5
    Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
    Collecting PyMuPDF==1.12.5
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/c1/4a/f6424f019bbc3ac70b55fd589f6b3eb777e13d1a3600dbdb726575d5f5df/PyMuPDF-1.12.5-cp36-cp36m-manylinux1_x86_64.whl (3.4 MB)
         |████████████████████████████████| 3.4 MB 1.2 MB/s            
    Installing collected packages: PyMuPDF
    Successfully installed PyMuPDF-1.12.5

    nice 终于装上了,启动服务,尝试进行文件拼接,直接报下面的错误:

    'Document' object has no attribute 'new_page'

    wtf,骇然不让人活了?

    尝试升级版本:

    [root@iZbp12k4fwg2euy5kkr9u7Z mupdf-1.12.0-source]# pip install PyMuPDF==1.18.19
    Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
    Collecting PyMuPDF==1.18.19
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/d8/b6/59c001fa851ec4ad216232bc256b9aaff67ff9cf1c4bb542f68f1ad5fcd8/PyMuPDF-1.18.19-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.4 MB)
         |████████████████████████████████| 6.4 MB 1.4 MB/s            
    Installing collected packages: PyMuPDF
      Attempting uninstall: PyMuPDF
        Found existing installation: PyMuPDF 1.12.5
        Uninstalling PyMuPDF-1.12.5:
          Successfully uninstalled PyMuPDF-1.12.5
    Successfully installed PyMuPDF-1.18.19

    世界终于清净了:

    总结:

    1. mupdf 源码安装选择mupdf-1.12.0 https://mupdf.com/downloads/archive/mupdf-1.20.0-source.tar.gz
    2. pip 安装选择1.18.19 pip install PyMuPDF==1.18.19

     



沪ICP备19023445号-2号
友情链接