首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Calibre ebook-找不到转换命令

Calibre ebook-找不到转换命令
EN

Stack Overflow用户
提问于 2015-09-07 01:18:51
回答 2查看 918关注 0票数 0

我正在学习Avdi Grimm关于Rake的教程系列,但我被Part 6卡住了。调用Pandoc的任务工作正常,但Calibre的ebook-convert命令返回状态127:

代码语言:javascript
复制
andrekibbe@Andres-MacBook rake_basics (master) $ rake
pandoc -o ch1.html ch1.md
pandoc -o ch2.html ch2.md
pandoc -o ch3.html ch3.md
pandoc -o subdir/appendix.html subdir/appendix.md
pandoc -o ch4.html ch4.markdown
cat ch1.html ch2.html ch3.html ch4.html  > book.html
ebook-convert book.html book.epub
rake aborted!
Command failed with status (127): [ebook-convert book.html book.epub...]
/Users/andrekibbe/code/rake_basics/Rakefile:27:in `block in <top (required)>'
/Users/andrekibbe/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/andrekibbe/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default => book.epub

ebook-convert在我的应用程序目录的路径中:/Applications/calibre.app/Contents/MacOS/calibre,而我的Rakefile在/Users/andrekibbe/code/rake_basics

代码语言:javascript
复制
require "rake/clean"

SOURCE_FILES = Rake::FileList.new("**/*.md", "**/*.markdown") do |fl|
  fl.exclude("~*")
  fl.exclude(/^scratch\//)
  fl.exclude do |f|
    `git ls-files #{f}`.empty?
  end
end
CLEAN.include(SOURCE_FILES.ext(".html"))

task default: ["book.epub", "book.mobi"]
task html: SOURCE_FILES.ext(".html")

rule ".html" => ->(f){source_for_html(f)} do |t|
  sh "pandoc -o #{t.name} #{t.source}"
end

file "book.html" => SOURCE_FILES.ext(".html") do |t|
  chapters   = FileList["**/ch*.html"]
  backmatter = FileList["backmatter/*.html"]
  sh "cat #{chapters} #{backmatter} > #{t.name}"
end
CLEAN.include("book.html")

file "book.epub" => "book.html" do |t|
  sh "ebook-convert book.html #{t.name}"
end
CLOBBER.include("book.epub")

file "book.mobi" => "book.epub" do |t|
  sh "kindlegen book.epub -o #{t.name}"
end
CLOBBER.include("book.mobi")

def source_for_html(html_file)
  SOURCE_FILES.detect{|f| f.ext('') == html_file.ext('')}
end

有没有办法要求Rakefile中的Calibre工具,比如gem,或者使用绝对路径或符号链接?我不认为这应该是必要的,因为在Avdi的代码中没有这样的东西。或者我需要在其他地方安装Calibre?

EN

回答 2

Stack Overflow用户

发布于 2016-08-24 12:25:38

退出代码127是“未找到命令”。http://otaku-elite.com/blog/2013/06/06/rake-status-127/

作为第一步,您可以尝试将电子书转换为的,然后使用完整路径。

票数 0
EN

Stack Overflow用户

发布于 2021-07-25 12:08:19

这是因为ebook-convert不在path中。您应该使用ebook-convert的完整路径或将其添加到路径中。

改变你的

代码语言:javascript
复制
ebook-convert book.html book.epub

代码语言:javascript
复制
/Applications/calibre.app/Contents/MacOS/ebook-convert book.html book.epub

或者将本地添加到/usr/ ln /bin,然后重试

代码语言:javascript
复制
sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32426215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档