Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when converting to pdf/reST #621

Closed
constatza opened this issue Jul 7, 2017 · 22 comments
Closed

error when converting to pdf/reST #621

constatza opened this issue Jul 7, 2017 · 22 comments
Milestone

Comments

@constatza
Copy link

When trying to download the file as .pdf or .rst the following error is raised:

500 : Internal Server Error
The error was:
nbconvert failed: 'charmap' codec can't decode byte 0x9a in position 127: 
character maps to <undefined>

I am running Windows and have folders with Greek Alphabet, could this cause the problem?

@mpacer
Copy link
Member

mpacer commented Jul 7, 2017

That is likely part of the problem. If you try to convert on the command line does it work?

@constatza
Copy link
Author

constatza commented Jul 7, 2017

Yeah, tried once the same issue. When it says " position 127", where does it refer to? If i could locate this position maybe i could fix it. The fact is that I don't even know how to start.

@takluyver
Copy link
Member

takluyver commented Jul 7, 2017 via email

@constatza
Copy link
Author

That won't work either, I use Anaconda with python 3.6.

@constatza
Copy link
Author

constatza commented Jul 7, 2017

Initially it raised an error because I hadn't installed pandoc, but since I installed it it raises the error I mentioned.

@mpacer
Copy link
Member

mpacer commented Jul 7, 2017

Does it work on any of the exporters? E.g., html, markdown, asciidoc, notebook, python…

or is it broken on every one of them?

@mpacer
Copy link
Member

mpacer commented Jul 7, 2017

Basically, if it works on at least one of them, we can say confidently that it's an issue with the particular exporters, and if it works on none of them, it's likely to be an issue with nbconvertapp & how it reads file names.

@constatza
Copy link
Author

constatza commented Jul 8, 2017

It works for all the exporters except for the .pdf and .rst

@constatza
Copy link
Author

constatza commented Jul 8, 2017

The home directory of jupyter is : C\users\Kωνσταντίνος . Should I try to change the home directory or the user's name? Which is better? I wouldn't like to try the latter, unless you guys are more or less sure that the folder's name causes the issue.

@constatza
Copy link
Author

constatza commented Aug 2, 2017

@mpacer
Apparently, it seems the error is caused by the notebook's content. I just tried to convert a notebook with no greek markdown text as title and it worked fine. Hence the greek titles are the problem.
So, do you have any suggestion to overcome this?

@takluyver
Copy link
Member

Can you show the whole of the traceback you get when you do it on the command line with the greek text? That should show us where in the code the error comes from.

@constatza
Copy link
Author

constatza commented Aug 3, 2017

C:\Users\Κωνσταντίνος\Google Drive\PythonNotebooks>jupyter nbconvert --to pdf olives.ipynb
[NbConvertApp] Converting notebook olives.ipynb to pdf

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\Scripts\jupyter-nbconvert-script.py", line 11, in <module>
    load_entry_point('nbconvert==5.2.1', 'console_scripts', 'jupyter-nbconvert')()
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 313, in start
    self.convert_notebooks()
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 481, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 452, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 381, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 172, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 190, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 162, in from_notebook_node
    nb, resources=resources, **kw
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\latex.py", line 82, in from_notebook_node
    return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 283, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jinja2\asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jinja2\_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\article.tplx", line 8, in top-level template code
    ((* extends cell_style *))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\style_ipython.tplx", line 60, in top-level template code
    ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) )))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\base.tplx", line 6, in top-level template code
    ((*- extends 'document_contents.tplx' -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\document_contents.tplx", line 50, in top-level template code
    ((*- block figure scoped -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\skeleton\display_priority.tplx", line 5, in top-level template code
    ((*- extends 'null.tplx' -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\skeleton\null.tplx", line 30, in top-level template code
    ((*- block body -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\base.tplx", line 173, in block "body"
    ((( super() )))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\skeleton\null.tplx", line 32, in block "body"
    ((*- block any_cell scoped -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\skeleton\null.tplx", line 85, in block "any_cell"
    ((*- block markdowncell scoped-*)) ((*- endblock markdowncell -*))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\..\templates\latex\document_contents.tplx", line 67, in block "markdowncell"
    ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown', 'json',extra_args=[]) | resolve_references | convert_pandoc('json','latex'))))
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\filters\pandoc.py", line 26, in convert_pandoc
    return pandoc(source, from_format, to_format, extra_args=extra_args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\utils\pandoc.py", line 51, in pandoc
    check_pandoc_version()
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\utils\pandoc.py", line 97, in check_pandoc_version
    v = get_pandoc_version()
  File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\utils\pandoc.py", line 79, in get_pandoc_version
    universal_newlines=True)
  File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 405, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 823, in communicate
    stdout = self.stdout.read()
  File "C:\ProgramData\Anaconda3\lib\encodings\cp1253.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9a in position 127: character maps to <undefined>

@takluyver
Copy link
Member

That's weird - that bit of code is only supposed to read the pandoc version number, which shouldn't depend on the notebook contents at all. Can you do pandoc -v in an anaconda terminal in that same directory and see what it shows?

Hopefully the fix will be quite simple, but I'd like to understand the problem better first.

@constatza
Copy link
Author

(C:\ProgramData\Anaconda3) C:\Users\Κωνσταντίνος\Google Drive\PythonNotebooks>pandoc -v
pandoc 1.19.2.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
Default user data directory: C:\Users\�ωνσταντίνος\AppData\Roaming\pandoc
Copyright (C) 2006-2016 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

mm that chinese...

@takluyver
Copy link
Member

Ah, it's trying to print your home directory. Luckily we can safely ignore that. PR coming up.

takluyver added a commit to takluyver/nbconvert that referenced this issue Aug 3, 2017
Allowing for non-ascii home directory on Windows. We only need to decode
the first line, not the whole output.

Closes jupytergh-621
@takluyver
Copy link
Member

Hopefully #638 should fix that. Can you give it a try? It's possible that there's another problem lurking behind this one.

@constatza
Copy link
Author

I will make a try.

@constatza
Copy link
Author

constatza commented Aug 3, 2017

Excuse my ignorance, I am not a professional programmer, is there a fast way to do this? or should I do it manually?
I am not sure I did right. I just changed the pandoc.py in the current anaconda environment did I get right?

@constatza
Copy link
Author

Yeah, it worked! Thank you guys! You are the best!

@takluyver takluyver added this to the 5.3 milestone Aug 3, 2017
@takluyver
Copy link
Member

Cool, thanks for testing it!

BTW, we normally close the issue when the pull request is merged. It's not really important here, though.

@constatza
Copy link
Author

constatza commented Aug 3, 2017

Do you want to reopen it?
Sorry I am newbie! Thanks again and sorry for consuming your time! I know you guys run tons of issues and never get tired! Good job! We all thank you!

@takluyver
Copy link
Member

We do get tired ;-). But it's still super satisfying when we can fix something that's clearly broken and make someone happy!

No need to reopen the issue, it was just a note for future issues you might report.

@mpacer mpacer modified the milestones: 5.3, no action Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants