繁体   English   中英

尽管使用 pip 和 sudo apt-get install 安装,但在 Ubuntu 上找不到 Pandoc

[英]Pandoc could not be found on Ubuntu despite installing with pip and sudo apt-get install

我正在使用 Nikola ,一个 static 网站生成器,来建立一个网站。 我正在通过Github Actions自动化它的构建。 我还想使用Pandoc帮助将我的 markdown 转换为 html,但我注意到 Pandoc 不包含在原始操作中。 因此,我不得不尝试弄清楚如何包含它。 但是,我一次又一次地被FileNotFound错误所挫败。

首先,我尝试编辑操作,以便在 Ubuntu 环境中安装 Pandoc。 下面是我编辑的动作版本。 我只Install Pandoc on Ubuntu

on: [push]

jobs:

    nikola-build:
       runs-on: ubuntu-latest
       steps:
       - name: Install Pandoc on Ubuntu
         run: sudo apt-get install -y pandoc

       - name: Check out
         uses: actions/checkout@v2

       - name: Build and Deploy Nikola
         uses: getnikola/nikola-action@v3
         with:
           dry_run: false

当这再次失败并通知我找不到 Pandoc 时,我在我的存储库中添加了一个requirements.txt文件:

Pandoc

我尝试再次运行该操作。 两种安装(我编写的操作步骤和pip install pandoc )都运行没有任何问题并且成功。 然而到了Nikola开始建站的那一步,好像不管怎么做都渲染失败,因为找不到Pandoc:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/nikola/plugins/compile/pandoc.py", line 76, in compile
    subprocess.check_call(['pandoc', '-o', dest, source] + self._get_pandoc_options(source))
  File "/usr/local/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/local/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pandoc'

我到处寻找类似问题的解决方案,但它们很少而且已经过时。 我将非常感谢您对这个问题的任何见解,有什么问题,我可以做些什么来解决它等等。

pandoc不是 Python package。 它是一个独立且非常强大的命令行工具。 nikola调用命令行工具来完成它的工作。 您需要使用他们建议的sudo apt install pandoc命令行来安装它。

我发现系统无法找到 Pandoc,因为整个项目是在 Docker 容器中运行的; 我之前在系统本身上安装了 Pandoc,但失败了。 我能够通过修改shell 脚本在容器中安装 Pandoc 来解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM