【问题标题】:how to install pkg-config on ec2 instance如何在 ec2 实例上安装 pkg-config
【发布时间】:2021-02-23 19:29:59
【问题描述】:

从我的 ec2 实例中,我正在尝试运行需要 html5-parse 的 python 脚本。当我尝试运行 python3 -m pip install html5_parser 时,我得到了,

Collecting html5_parser
  Using cached https://files.pythonhosted.org/packages/a6/78/6a80c13be6c02fd2fb615b473a6ceff5b28bafca184f428ab197f677fd7a/html5-parser-0.4.9.tar.gz
    Complete output from command python setup.py egg_info:
    Package libxml-2.0 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libxml-2.0.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libxml-2.0' found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-bo946lpx/html5-parser/setup.py", line 79, in <module>
        include_dirs=include_dirs(),
      File "/tmp/pip-build-bo946lpx/html5-parser/build.py", line 94, in include_dirs
        return [x[2:] for x in pkg_config('libxml-2.0', '--cflags-only-I')]
      File "/tmp/pip-build-bo946lpx/html5-parser/build.py", line 76, in pkg_config
        val = subprocess.check_output([PKGCONFIG, pkg] + list(args)).decode('utf-8')
      File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
        **kwargs).stdout
      File "/usr/lib/python3.6/subprocess.py", line 438, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['pkg-config', 'libxml-2.0', '--cflags-only-I']' returned non-zero exit status 1.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bo946lpx/html5-parser/

如何在 ubuntu 上安装 pkg-config 以便最终安装 html5-parser?

【问题讨论】:

    标签: ubuntu amazon-ec2 pip pkg-config


    【解决方案1】:

    html5-parser可以通过apt在Ubuntu中安装:

    sudo add-apt-repository universe
    sudo apt update
    sudo apt install python3-html5-parser
    

    【讨论】:

      【解决方案2】:

      对于html5_parser,您需要lxml。所以从 https://lxml.de/installation.html#requirements

      sudo apt-get install libxml2-dev libxslt-dev python-dev
      

      其余的见https://html5-parser.readthedocs.io/en/latest/#unix

      pip install --no-binary lxml html5-parser
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-13
        • 1970-01-01
        • 1970-01-01
        • 2016-10-23
        • 1970-01-01
        相关资源
        最近更新 更多