PDFMathTranslate icon indicating copy to clipboard operation
PDFMathTranslate copied to clipboard

docker启动报错libgthread-2.0.so.0: cannot open shared object file: No such file or directory(v1.9.0)

Open JiyongShi opened this issue 1 year ago • 14 comments

问题描述

1.9.0 docker启动报错: /usr/local/lib/python3.12/site-packages/stanza/models/common/beam.py:6: SyntaxWarning: invalid escape sequence '\ ' """ Traceback (most recent call last): File "/usr/local/bin/pdf2zh", line 4, in from pdf2zh.pdf2zh import main File "/usr/local/lib/python3.12/site-packages/pdf2zh/init.py", line 2, in from pdf2zh.high_level import translate, translate_stream File "/usr/local/lib/python3.12/site-packages/pdf2zh/high_level.py", line 25, in from pdf2zh.doclayout import OnnxModel File "/usr/local/lib/python3.12/site-packages/pdf2zh/doclayout.py", line 4, in import cv2 File "/usr/local/lib/python3.12/site-packages/cv2/init.py", line 181, in bootstrap() File "/usr/local/lib/python3.12/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

测试文档

services: pdfmathtranslate: image: byaidu/pdf2zh:v1.9.0 container_name: pdfmathtranslate restart: unless-stopped ports: - 7860:7860 volumes: - ./data/pdf2zh_files:/app/pdf2zh_files

JiyongShi avatar Jan 24 '25 02:01 JiyongShi

https://stackoverflow.com/questions/62786028/importerror-libgthread-2-0-so-0-cannot-open-shared-object-file-no-such-file-o 在docker容器里按照网页的说明安装一下libglib2.0-0试一下吧,这个可能是个特例。

hellofinch avatar Jan 24 '25 02:01 hellofinch

同样报了这个错误,在watchover自动升级到最新版了之后。

SamDu1998 avatar Jan 24 '25 02:01 SamDu1998

RUN apt-get update &&
apt-get install --no-install-recommends -y libgl1 libglib2.0-0 curl &&
rm -rf /var/lib/apt/lists/* && uv pip install --system --no-cache huggingface-hub &&
增加安装 libglib2.0-0可以,windows和另外一台linux都是这个错误,可能debian系的都会有异常

JiyongShi avatar Jan 24 '25 02:01 JiyongShi

感谢(但是我在用的Ubuntu好像无法安装上pip install --system --no-cache huggingface-hub )我这边再研究一下

SamDu1998 avatar Jan 24 '25 05:01 SamDu1998

运行 apt-get update && apt-get install --no-install-recommends -y libgl1 libglib2.0-0 curl && rm -rf /var/lib/apt/lists/* && uv pip install --system --no -cache Huggingface-hub && 增加安装libglib2.0-0就可以,windows和另外一个linux都是这个错误,可能debian系的都会有异常

docker启动后不到10秒就关闭,根本来不及敲入命令,不就直接修改好镜像???从1.8开始就一直遇到这个问题

ariesbi avatar Jan 25 '25 00:01 ariesbi

I got the same err on Mac

peterjun69 avatar Jan 25 '25 02:01 peterjun69

看到release里的dockerfile里有“RUN apt-get update && apt-get install -y libgl1”, 是不是应该改为“RUN apt-get update && apt-get install -y libgl1 libglib2.0-0“才对呢

peterjun69 avatar Jan 25 '25 03:01 peterjun69

Use this Dockerfile to build docker image for Debian/Ubuntu:

FROM byaidu/pdf2zh:v1.9.0

RUN apt update && \
  apt install -y libglib2.0-0

Run docker build -t localimage/pdf2zh:v1.9.0 . and use localimage/pdf2zh:v1.9.0 as image.

eli-yip avatar Jan 25 '25 08:01 eli-yip

Use this Dockerfile to build docker image for Debian/Ubuntu:

FROM byaidu/pdf2zh:v1.9.0

RUN apt update &&
apt install -y libglib2.0-0

Run docker build -t localimage/pdf2zh:v1.9.0 . and use localimage/pdf2zh:v1.9.0 as image.

尝试了你的方法也不行,编译不成功,一直会提示 E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/*.bin || true' E: Sub-process returned an error code The command '/bin/sh -c apt update && apt install -y libglib2.0-0' returned a non-zero code: 100 不知道你们有碰到这样的问题吗

jinpf304 avatar Jan 26 '25 06:01 jinpf304

Use this Dockerfile to build docker image for Debian/Ubuntu: FROM byaidu/pdf2zh:v1.9.0 RUN apt update && apt install -y libglib2.0-0 Run docker build -t localimage/pdf2zh:v1.9.0 . and use localimage/pdf2zh:v1.9.0 as image.

尝试了你的方法也不行,编译不成功,一直会提示 E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/*.bin || true' E: Sub-process returned an error code The command '/bin/sh -c apt update && apt install -y libglib2.0-0' returned a non-zero code: 100 不知道你们有碰到这样的问题吗

你这个是权限问题吧,删除缓存不成功,可能和你的环境有关系

peterjun69 avatar Jan 26 '25 13:01 peterjun69

Use this Dockerfile to build docker image for Debian/Ubuntu: FROM byaidu/pdf2zh:v1.9.0 RUN apt update && apt install -y libglib2.0-0 Run docker build -t localimage/pdf2zh:v1.9.0 . and use localimage/pdf2zh:v1.9.0 as image.

尝试了你的方法也不行,编译不成功,一直会提示 E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/*.bin || true' E: Sub-process returned an error code The command '/bin/sh -c apt update && apt install -y libglib2.0-0' returned a non-zero code: 100 不知道你们有碰到这样的问题吗

你这个是权限问题吧,删除缓存不成功,可能和你的环境有关系

这个dockerfile编译怎么提权呀?没碰到过

jinpf304 avatar Jan 27 '25 01:01 jinpf304

i wrote docker-compose.yaml and run.sh

docker-compose.yaml

services:
  pdf2zh:
    image: byaidu/pdf2zh
    container_name: pdf2zh
    build:
      context: .
      dockerfile_inline: |
        FROM byaidu/pdf2zh:v1.9.0
        RUN apt update && \
          apt install -y libglib2.0-0
    ports:
      - "7860:7860"
    restart: unless-stopped

run.sh

docker compose up \
  --build \
  -d

Image

QED.

yeoli9 avatar Jan 27 '25 12:01 yeoli9

这个问题是dockerfile的安装不太对 我把第18行libglib2.0-0 改成 libglib2.0-dev 然后重新built就好了

billylicn avatar Jan 29 '25 15:01 billylicn

通过创建dockerfile并添加代码修复好了,步骤如下(感谢Claude):

创建自定义 Dockerfile

在同一目录下创建 Dockerfile:

# Linux/Mac 系统使用:
touch Dockerfile
nano Dockerfile   # 或者用 vim Dockerfile

# Windows 系统可以:
echo. > Dockerfile
notepad Dockerfile  # 或使用其他文本编辑器

并添加如下两行代码:

FROM byaidu/pdf2zh RUN apt-get update && apt-get install -y libglib2.0-0 && rm -rf /var/lib/apt/lists/*

修改 docker-compose.yml:

version: '3'
services:
  pdf2zh:
    build: .  # 替换 image 行为 build
    container_name: pdf2zh
    ports:
      - "7860:7860"

重新构建和启动:

docker-compose up --build -d

SamDu1998 avatar Feb 04 '25 03:02 SamDu1998