jceb / vim-orgmode

Text outlining and task management for Vim based on Emacs' Org-Mode
http://www.vim.org/scripts/script.php?script_id=3642
Other
3.1k stars 266 forks source link

Export as PDF fails with Python TypeError #279

Open m-putnam opened 6 years ago

m-putnam commented 6 years ago

This happens with any attempt export of an orgmode file to pdf with \ep, even when input file contents are simply the word test:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/redacted/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 90, in topdf
    ret = cls._export(u'org-latex-export-to-pdf')
  File "/home/redacted/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 84, in _export
    echom('\n'.join(p.communicate()))
TypeError: sequence item 0: expected str instance, bytes found

Vim version is 8.0.1171, Python is 3.6.1.

Psirus commented 6 years ago

@Pbtflakes Can you test if the commit by @aeroaks fixes your problem?

m-putnam commented 6 years ago

Just tried that, it fixes one error but export still stops on a different one:

Traceback (most recent call last):                       
  File "<string>", line 1, in <module>
  File "/home/redacted/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 90, in topdf
    ret = cls._export(u'org-latex-export-to-pdf')
  File "/home/redacted/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 84, in _export
    echom(b'\n'.join(p.communicate()))
  File "/home/redacted/.vim/plugged/vim-orgmode/ftplugin/orgmode/_vim.py", line 109, in echom
    for m in message.split(u'\n'):
TypeError: a bytes-like object is required, not 'str'

Just a note, it only seems to do the full export procedure and error when the output PDF doesn't already exist, otherwise it runs through and leaves the existing one.

RaitaroH commented 4 years ago

This wasn't an issue for me when I was on KDE Neon based on Ubuntu 18.04. I had pandoc emacs texlive-full python python-pip installed (python 2 and 3 were installed). Now I moved to manjaro and I get this issue. I have pandoc emacs texlive-core python python-pip installed and vim-orgmode was only just updated a few minutes ago withD :PlugUpdate. I thought maybe an update would fix this issue. But now I tried modifying a file from a month ago (on neon it exported fine), but now I just get the issue posted above. And I manually made the edit from 279 and it doesn't work for me. The error becomes as such with that change:

Error detected while processing :
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/raitaro/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 91, in topdf
ret = cls._export(u'org-latex-export-to-pdf')
File "/home/raitaro/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Export.py", line 85, in _export
echom('\n'.join(map(lambda x: x.decode(), p.communicate())))
File "/home/raitaro/.vim/plugged/vim-orgmode/ftplugin/orgmode/_vim.py", line 110, in echom
vim.command(u_encode(u':echomsg "%s"' % m))
vim.error: Vim(echomsg):E121: Undefined variable: home
RaitaroH commented 4 years ago

Actually... I fixed it. At first I just thought is because texlive-most might have something I need. I am not sure about that, but installing it did not fix the issue.

What did for me was simply moving \newcommand definitions from

#+BEGIN_LATEX
....
#+END_LATEX

to #+Latex_Header: at the beginning of the document. I have no idea why this is like that. It worked absolutely fine before. This https://github.com/jceb/vim-orgmode/pull/291 doesn't seem to be needed.

There are 2 problems with this: vim gets a bit confused with highlighting and having long \newcommand makes the beginning of the file look horrible and also makes modifications of those newcommand harder.