Comments (13)
ok I solved the problem : If the filter is not executable, the shebang is ignored and the default python env is used:
jgm/pandoc#3174
A simple chmod a+x /tmp/headers.py
fixed issue.
Indeed the filters works fine with a python3 environment...
You should problably write somewhere in the documentation that Python2 is not well supported.
Thanks for your time and for this software !
from panflute.
Hi Daamien,
Do you have access to py3? If so, could you try running it there to see if the issue persists?
The py2 version of Panflute should work, but that version is mostly built automatically with 3to2, so I'm not that surprised to see unicode issues. In this specific case, the bug might be related with json.load missing an encoding option, but as per the py2 manual, json.load should have defaulted to utf-8 encoding and not ascii encoding. Since I don't have py2 installed on my laptop, I'm not sure if I can fix the issue (unless it also occurs on py3), but if you or another user submit a PR I can merge it for sure.
Best,
Sergio
from panflute.
ok I'll give it a try....
If I install a python3 on machine with python2, how can I force pandoc to use python3 to interpret the filter ?
from panflute.
Yes, there are several ways for this depending on your system:
On *nix, you could use shebang lines: https://docs.python.org/3/using/windows.html#shebang-lines
On windows, I think there is a new utility called "py" that comes with the latest version of py2 or py3, which also allow shebangs.
from panflute.
Sorry to bother with that but pandoc seems to use python2 only....
The shebang is there
cat /tmp/headers.py
#!/usr/bin/python3
panflute is installed with pip3
# pip3 install panflute
Requirement already satisfied (use --upgrade to upgrade): panflute in /usr/local/lib/python3.4/dist-packages
Cleaning up...
But pandoc still fails like this
pandoc tests/french_title.md --filter /tmp/headers.py -o test.pdf
Traceback (most recent call last):
File "/tmp/headers.py", line 3, in <module>
from panflute import run_filter, Header
ImportError: No module named panflute
pandoc: Error running filter /tmp/headers.py
Filter returned error status 1
In the python3 console, i can load panflute :
# python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import panflute
>>>
from panflute.
Great to hear that! And yes, I agree about python 2 support (which as of now, mostly depends on external commiters)
from panflute.
I faced Very similar situation(Japanese) :)
from panflute.
Hi Kazuki,
Does it work on py3?
from panflute.
no worries
no problem it worked with py3
I was also using py2
from panflute.
There are similar issues with autofilters and unicode literals in the Python source, which can be traced there:
panflute/panflute/autofilter.py
Lines 83 to 85 in b9bc64c
I fixed it with open(fn, encoding="utf-8")
, but I'm not sure if that's the best solution (this ignores any encoding headers in the python source)
from panflute.
I fixed it with open(fn, encoding="utf-8"), but I'm not sure if that's the best solution (this ignores any encoding headers in the python source)
@damiendr I wouldn't mind adding it, but one question: is this a py2 or py3 issue?
from panflute.
This is with Python 3.
from panflute.
Making the python filters executable solved my problem too, that should be added to the installation documentation.
from panflute.
Related Issues (20)
- Creating a Panflute filter that interacts with other filters HOT 1
- Reimplement the panflute.stringify with native pandoc writer HOT 2
- Unable to get Panflute filter comments.py to work correctly HOT 1
- Add comparison method to Element class? HOT 2
- Compatibility with Pandoc 2.18 HOT 3
- Using panflute as a writer rather than a filter HOT 8
- Stringifying the terms of a definition list results in AttributeError HOT 7
- Hwo to use the span method? HOT 1
- Applying panflute filter multiple times generates an unexpected result
- Can't convert markdown style citations to LaTeX style using panflute filter HOT 5
- Navigation with next and prev unstable HOT 3
- Add space before footnote in stringify function HOT 4
- Is there solution to add custom style for lists with panflute ? HOT 2
- Avoid side-effects in walk
- Figure, Table: to_json() crashes if caption is None HOT 1
- Reading the value of `--resource-path` inside a panflute filter ? HOT 3
- Trying to create new metadata from metadata
- Removal of click dependency HOT 3
- Installing globally on Ubuntu HOT 2
- Consider different check for RawInline formats?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panflute.