python, pythontex and plots

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Sep 22 23:38:28 EDT 2013


chitturk, you will probably get better answers if you actually explain 
your question rather than writing as if we can read your mind. More 
comments below:

On Sun, 22 Sep 2013 19:16:35 -0700, chitturk wrote:

> 1) The file is LaTeX
> 2) the % means LaTeX will ignore it.

Shouldn't you ask this on a LaTeX forum then? How is your problem related 
to Python? If it is a Python error, you should explain how you know it is 
a Python error rather than a LaTeX error, because to me it looks like a 
LaTeX error.


> 3) The question was about using pythontex with LaTeX 

And pythontex is what? An interface to Python via LaTeX? Are you getting 
a Python error or a LaTeX error? It seems to me that you are getting a 
LaTeX error, and that Python is irrelevant here. If you have information 
that suggests otherwise, you should share it with us.


4) I included the file so you (OK, others) could see what I was trying 

Problem is that it is not clear what parts are the file and what parts, 
if any, are your commentary on the file. You shouldn't assume that Python 
programmers will be experts on LaTeX syntax and be able to read your code.


> 5) The problem had to do with accessing a file name within the python
>    script using \py{outputfile}

If I am reading your file/comments correctly, the error you get is not a 
Python error, but a LaTeX error:


%! File ended while scanning definition of \filename at base. %<inserted
text>
%                }
% no pdf


If I am wrong, explain to me how you decided that this was a Python error 
rather than LaTeX. I've been using Python for over 15 years, and this is 
the first time I've seen anything even remotely like that. 

It is not clear to me whether "no pdf" is your comment, the output of 
pythontex, the output of LaTeX, or something else. It is also not clear 
whether %<inserted text> is literally part of the output, or just a 
placeholder for something you thought was irrelevant.


> 6) pythontex is a terrific package that I enjoy using 

Glad to hear it.


> 7) I was looking for help on debugging this error. 
> 8) I was trying to find out why I could not do \py{outfilename}

\py{outputfilename} isn't Python code, so I'm not sure why you think a 
Python forum is the right place to ask about this. For us to help you, 
we'll probably need to know:

- What is outputfilename?

- Are you sure it corresponds to an actual file? A readable file?
  (Check the permissions.) Containing the right output? E.g. if you're
  expecting a PDF file, but giving it a PNG file, it probably won't work.

- What Python code ends up being executed when you run \py
  {outputfilename}?

- Can you run that code successfully from Python itself, bypassing
  pythontex?

- If not, what result did you expect? What result did you get?

- If you got an exception, what was the entire exception?

- Any other relevant information that comes up while investigating.


Help us to help you. Excessively concise questions written for an 
audience who already knows everything you know is not likely to get a lot 
of help.


-- 
Steven



More information about the Python-list mailing list