Error when unicode character with add_image
See original GitHub issueHello, The first code below is working, but the second raises an error. Of course, both /home/mth/nounicode.jpg and /home/mth/unicodé.jpg exist (and both are the same duplicate picture).
#!/usr/bin/env python
# coding: utf-8
from pylatex import Document, Figure
doc = Document()
with doc.create(Figure(position='h!')) as kitten_pic:
kitten_pic.add_image('/home/mth/nounicode.jpg') # No problem with this name
doc.generate_pdf('toto', clean_tex=False)
#!/usr/bin/env python
# coding: utf-8
from pylatex import Document, Figure
doc = Document()
with doc.create(Figure(position='h!')) as kitten_pic:
kitten_pic.add_image('/home/mth/unicodé.jpg') # The name with é raises an error
doc.generate_pdf('toto', clean_tex=False)
>>>
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pylatex/document.py", line 228, in generate_pdf
stderr=subprocess.STDOUT)
File "/usr/lib/python3.4/subprocess.py", line 620, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'toto.tex']' returned non-zero exit status 12
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mth/Pb accents.py", line 11, in <module>
doc.generate_pdf('toto', clean_tex=False)
File "/usr/local/lib/python3.4/dist-packages/pylatex/document.py", line 239, in generate_pdf
print(e.output.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 3116: invalid continuation byte
In the log file, I find this :
LaTeX Warning: File `/home/mth/unicod\IeC {\'e}.jpg' not found on input lin
e 17.
! Package pdftex.def Error: File `/home/mth/unicod\E9.jpg' not found.
See the pdftex.def package documentation for explanation.
Type H <return> for immediate help.
...
l.17 ...0.8\textwidth]{/home/mth/unicodé.jpg}
%
Using draft setting for this image.
Would you have a clue to how I could manage this kind of situation ? By the way, thank you for your work !
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Unicode character in image filename makes sphinx crash #2395
Unicode character in image filename makes sphinx crash #2395 ... The Error is related to line 203 in sphinx.util.i18n.
Read more >unicode characters in image URL - 404 - Stack Overflow
I am trying to open an image that has Latin characters in its name ... mysite.com/images/113_Atl%C3%A9tico%20Madrid.png I got 404 error.
Read more >U+2069 error when adding image in TeXShop - TeX
I am trying to add an image into the document on TeXShop but keep seeing this error: Package inputenc Error: Unicode character (U+2069) ......
Read more >Add image from my files - General Usage - Julia Discourse
I'm trying to load an image that I have on my computer, but I get this error … someone can audare me …...
Read more >How to stamp image on existing PDF and create an anchor?
addImage (image); stamper.close();. Any idea how to do this? Posted on StackOverflow on Nov ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No problem. Thanks for the info. I’ll leave the issue open for now and will maybe fix it myself using your snippets in the future when I have some time.
I’m afraid I can’t do that. I have no idea how to create a pull request, and I am an amateur in python. However I watched in the code, and I would suggest to add this lines in the
class StandAloneGraphic
from figure.py, first in thedef __init__
function :But I’m not sure if
packages.add
will work (in my case, I was usingdoc.packages.add
instead).Also, what if someone doesn’t use utf8 as encoding but something else ? (might be rare though).
I’m afraid that’s all I can do myself. Thank you very much, sorry I can’t help more.