-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Windows usetex=True error in long usernames #5923
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
Comments
I suspect we just need to do some sort of filename escaping here -- but not having a Windows box I'm not exactly sure what... Thoughts, @JanSchulz ? |
You mean here: matplotlib/lib/matplotlib/backends/backend_ps.py Line 1297 in c32bb0d
|
Yep!, |
[lines: click on the line number and the URL will be set to that line :-) ] I can't reproduce that here:
Can you sent me the output you get from the last two lines and also the output of
Is supect that one of the env vars is set to the short name:
|
I see,
|
ok... Can you tests this (it worked in my plain python only conda 2.7 env):
https://stackoverflow.com/questions/11420689/how-to-get-long-file-system-path-from-python-on-windows I've actually no idea which package this file is from. |
The other idea would be to escape the ~ in the latex call: https://tex.stackexchange.com/questions/183568/using-8-3-path-names-with-pdflatex |
I did not have win32file library installed, and could not install trivially with pip, I guess because I run 64 bit python... And about escaping the ~ on the latex, not really sure how to do that, is it a setting for latex call, or a system setting? |
I also didn't install anything, it just came with condas python. Not sure if it is part of python itself? [Update: a bit of googling tells me that it is part of pywin32 :-( ] re the latex call:
[if the tex file is still there, which I hope it is] |
Ok, can you check if this helps:
if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
else: precmd = ''
- command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"'\
+ command = '%s cd "%s" && latex -interaction=nonstopmode \\input{%s} > "%s"'\
%(precmd, tmpdir, latexfile, outfile)
verbose.report(command, 'debug') |
Hello, I see, I tried the changes, but did not work, I got "undefined control sequence" from latex. not really sure how it works, but apparently it think that \ character is now calling a function. On the same page, I tried this: command=command.replace("~","\\string~") which I based on https://tex.stackexchange.com/questions/183568/using-8-3-path-names-with-pdflatex and works for me!. |
Wanna do a PR based on |
Ok!, Let me figure out how that works haha |
fix for latex call on PS backend closes #5923
fix for latex call on PS backend closes matplotlib#5923
Hello,
If I turn usetex=True, in rcParams and then try to save a figure using
plt.savefig("xxx.eps")
I get the error message at the end of the post.I tracked this down, and the issue is with the temporary file created by
tempfile.mkstemp()
in the function _print_figure_tex on backend_ps.py. This file, when the username in windows is long, it is shortened to 6 characters + "~1", then when running latex, the ~ is interpreted as a line break, therefore giving the error.I perform a simple fix on backend_ps.py, which is simply replace the short version of the username for the full name. This completely solves the problem for me:
Do not know how to proceed though in order for this "fix" to be checked/included/discarded...
Thanks!
Now the complete error message ( I changed the visible part of my username to xxxxxx):
The text was updated successfully, but these errors were encountered: