You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下apt和pip安装Pandoc后Nikola构建仍提示找不到Pandoc

问题原因分析

  • 核心问题1:你使用的getnikola/nikola-action@v3是Docker容器型Action,所有构建逻辑都在独立的容器环境内执行,你在宿主Ubuntu runner上执行的apt install pandoc安装的二进制文件无法被容器内的环境访问,等于完全没装。
  • 核心问题2:你通过requirements.txt安装的Pandoc是Python封装库,本身不包含Pandoc的二进制可执行文件,只是调用系统Pandoc的工具,所以即使安装成功也解决不了缺失二进制的问题。

可行修复方案

方案一:替换为手动构建流程(推荐,最稳定)

直接放弃容器型的nikola-action,手动编写构建步骤,所有逻辑直接在Ubuntu runner上执行,你提前安装的Pandoc可以正常被识别:

on: [push]

jobs:
  nikola-build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v4
        with:
          submodules: true
          fetch-depth: 0

      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get install -y pandoc python3-pip

      - name: Install Python dependencies
        run: pip3 install nikola[extras]

      - name: Build Nikola site
        run: nikola build

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./output

可根据自己的部署需求调整最后的部署步骤。

方案二:自定义Nikola Action的构建前置命令

如果你还是想使用官方nikola-action,可以给它传入pre_build参数,让它在容器内部执行Pandoc的安装操作:

on: [push]

jobs:
  nikola-build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out
        uses: actions/checkout@v2

      - name: Build and Deploy Nikola
        uses: getnikola/nikola-action@v3
        with:
          dry_run: false
          pre_build: |
            apt-get update
            apt-get install -y pandoc

内容的提问来源于stack exchange,提问作者Cary Thurston

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 10:24:02