在docker容器中安装Libpostal

问题描述 投票:0回答:1

有什么解决方案可以在正在运行的容器中安装 libpostal 吗?

我在输入

pip install postal
时遇到此错误:

ERROR: Could not build wheels for postal, which is required to install pyproject.toml-based projects
.

 running build_ext
      building 'postal._expand' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/postal
      gcc -pthread -B /opt/conda/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -I/usr/local/include -I/opt/conda/include/python3.11 -c postal/pyexpand.c -o build/temp.linux-x86_64-cpython-311/postal/pyexpand.o -std=c99
      postal/pyexpand.c:2:10: fatal error: libpostal/libpostal.h: No such file or directory
          2 | #include <libpostal/libpostal.h>
            |          ^~~~~~~~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for postal
  Running setup.py clean for postal
Failed to build postal
ERROR: Could not build wheels for postal, which is required to install pyproject.toml-based projects
$ pip install libpostal
ERROR: Could not find a version that satisfies the requirement libpostal (from versions: none)
ERROR: No matching distribution found for libpostal

经过多方研究,还是无法来安装。

这是我的

docker-compose.yml
文件:

version: '3.9'

services:
  jupyter:
    container_name: jupyter
    image: jupyter/pyspark-notebook:latest
    volumes:
      - .:/home/jovyan/
    ports:
      - "8888:8888"
python docker docker-compose postal-code postal
1个回答
0
投票

postal
libpostal
的 Python 绑定只是绑定 - 并且在安装时不包含任何核心基础模型组件。

根据文档,在使用 Python 绑定之前,您需要在容器/执行环境中安装

libpostal
C 库本身

由于您尝试使用的

jupyter/pyspark-notebook
容器是基于 Ubuntu 的,因此您可以按照任一链接的
README
中标有“On Ubuntu/Debian”的指导进行操作:

安装

在使用 Python 绑定之前,必须安装 libpostal C 库。确保您满足以下先决条件:

在 Ubuntu/Debian 上

sudo apt-get install curl autoconf automake libtool python-dev pkg-config

[...]

安装libpostal

git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
./configure --datadir=[...some dir with a few GB of space...]
make
sudo make install

# On Linux it's probably a good idea to run
sudo ldconfig

一个常见的陷阱:请确保将

[...some dir with a few GB of space...]
占位符更新为已安装文件系统上的绝对引用,其中
libpostal
Makefile
可以下载您需要的各种权重和支持文件。

构建完成后,您将能够安装最初尝试使用的 Python 绑定:

python3 -m pip install postal
© www.soinside.com 2019 - 2024. All rights reserved.