目标

目标

目标

要得到pandocfilters使用 pip3 运行。

我的错误

这是我重现错误的步骤。

  1. 通过 pip3 安装 pandocfilters:pip3 install pandocfilters
  2. 将脚本examples/caps.py和下载examples/plantuml.py~/.pandoc/filters/。(显示的默认用户数据位置pandoc -v~/.pandoc。)
  3. 附加3到的第一行plantuml.py,使其变成#!/usr/bin/env python3
  4. 将 Markdown 编译为 PDF pandoc foo.md -o bar.pdf --filter plantuml.py:。

错误信息:

Traceback (most recent call last):
  File "/home/vin100/.pandoc/filters/plantuml.py", line 14, in <module>
    from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_caption, get_extension
ImportError: No module named pandocfilters
pandoc: Error running filter /home/vin100/.pandoc/filters/plantuml.py
Filter returned error status 1

如何让 pandocfilter 与 pip3 协同工作?

技术细节

第 14 行plantuml.py节目

from pandocfilters import toJSONFilter, Para, Image, get_filename4code, get_caption, get_extension

我已经确认我确实安装了 pandocfilters。

$ pip3 freeze | grep pandocfilters
pandocfilters==1.4.2

安装位置是~/.local/lib/python3.6/site-packages

$ pip3 show pandocfilters
Name: pandocfilters
Version: 1.4.2
Summary: Utilities for writing pandoc filters in python
Home-page: http://github.com/jgm/pandocfilters
Author: John MacFarlane
Author-email: [email protected]
License: UNKNOWN
Location: /home/vin100/.local/lib/python3.6/site-packages
Requires: 

ls这是上面的输出Location

$ pip3 show pandocfilters | grep home | cut -d' ' -f2 | xargs ls -al
total 160
drwx------ 28 vin100 vin100  4096 Jul  3 10:00 .
drwx------  3 vin100 vin100  4096 Jun  2  2019 ..
drwxr-xr-x  7 vin100 vin100  4096 Jun  2  2019 awscli
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 awscli-1.16.169.dist-info
drwxr-xr-x  6 vin100 vin100  4096 Jun  2  2019 botocore
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 botocore-1.12.159.dist-info
drwxr-xr-x  3 vin100 vin100  4096 Jun  2  2019 colorama
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 colorama-0.3.9.dist-info
drwxr-xr-x  6 vin100 vin100  4096 Jun  2  2019 dateutil
drwxr-xr-x  9 vin100 vin100  4096 Jun  2  2019 docutils
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 docutils-0.14.dist-info
drwxr-xr-x  3 vin100 vin100  4096 Jun  2  2019 jmespath
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 jmespath-0.9.4.dist-info
drwxr-xr-x  2 vin100 vin100  4096 Aug  3 22:44 pandocfilters-1.4.2.dist-info
-rw-r--r--  1 vin100 vin100  8271 Aug  3 22:44 pandocfilters.py
drwxr-xr-x  2 vin100 vin100  4096 Jul  3 10:00 pandoc_mermaid_filter-0.1.0.dist-info
-rw-r--r--  1 vin100 vin100  1154 Jul  3 09:59 pandoc_mermaid_filter.py
drwxr-xr-x  6 vin100 vin100  4096 Jun  2  2019 pyasn1
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 pyasn1-0.4.5.dist-info
drwxr-xr-x  2 vin100 vin100  4096 Jul  3 10:00 __pycache__
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 python_dateutil-2.8.0.dist-info
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 PyYAML-3.13.dist-info
drwxr-xr-x  3 vin100 vin100  4096 Jun  2  2019 rsa
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 rsa-3.4.2.dist-info
drwxr-xr-x  3 vin100 vin100  4096 Jun  2  2019 s3transfer
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 s3transfer-0.2.0.dist-info
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 six-1.12.0.dist-info
-rw-r--r--  1 vin100 vin100 32452 Jun  2  2019 six.py
drwxr-xr-x  6 vin100 vin100  4096 Jun  2  2019 urllib3
drwxr-xr-x  2 vin100 vin100  4096 Jun  2  2019 urllib3-1.25.3.dist-info
drwxr-xr-x  3 vin100 vin100  4096 Jun  2  2019 yaml

pandocfilter 是一个单文件模块。从相关的官方 Python 教程,第 14 行plantuml.py对我来说看起来不错。我将其理解为from <script_file_name> import <script_method_name>

我不怎么写 Python 代码,我的$PYTHONPATH是空的。


根据评论进行编辑,感谢byzanz-gui

Python3 响应 在此处输入图片描述

相关内容