Re: Python-generated diagram as external material
John K john...@... writes: OK I tried this. I defined a new Python file format with extension .py in Lyx, and then created a Python - PDF (pdflatex) converter that runs the command: python $$i $$o But when I try exporting the document to PDF I get the following error: No information for converting python format files to png. Define a converter in the preferences. Why is it trying to convert to PNG? J What you did seems all correct. I don't know what the problem might be, because as far as I know PDF should be used for output and PNG used only to display the image within the LyX window. Perhaps someone else has more experience with this. -- Julien
Re: Python-generated diagram as external material
John K john...@... writes: OK I tried this. I defined a new Python file format with extension .py in Lyx, and then created a Python - PDF (pdflatex) converter that runs the command: python $$i $$o But when I try exporting the document to PDF I get the following error: No information for converting python format files to png. Define a converter in the preferences. Why is it trying to convert to PNG? J What you did seems all correct. I don't know what the problem might be, because as far as I know PDF should be used for output and PNG used only to display the image within the LyX window. Perhaps someone else has more experience with this. -- Julien
RE: Python-generated diagram as external material
>> I added the following to the Lyx external_templates file: >> >> Template Python >> GuiName "Python: $$AbsOrRelPathParent$$Basename" >> HelpText >> Python diagram. >> HelpTextEnd >> InputFormat "*" > > I think you need to define an input format and a .py -> .pdf converter which > runs the python interpreter on your file. > >> FileFilter "*.py" >> AutomaticProduction true >> Preview Graphics >> Format PDFLaTeX >> Product "\\includegraphics{$$AbsPath$$Basename.pdf}" >> Requirement "graphicx" >> UpdateCommand "python $$AbsPath$$Basename.py" > > I haven't seen any description for "UpdateCommand" anywhere. Where does that > come from? It's not in the documentation, or? > >> UpdateFormat pdf >> UpdateResult "$$AbsPath$$Basename.pdf" >> Requirement "graphicx" >> ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" >> FormatEnd >> TemplateEnd >> >> However, when I insert the Python script in Lyx, it draws a box that says > "Error converting to loadable >> format". > > Yes, because LyX doesn't know how to convert a python file to a graphics > file. > Try the way I described above: defining the file format and converter under > the > menu : Tools> Preferences...> File Handling. OK I tried this. I defined a new Python file format with extension .py in Lyx, and then created a Python -> PDF (pdflatex) converter that runs the command: python $$i $$o But when I try exporting the document to PDF I get the following error: "No information for converting python format files to png. Define a converter in the preferences." Why is it trying to convert to PNG? J _ Browse profiles for FREE! Meet local singles online. http://clk.atdmt.com/NMN/go/150855801/direct/01/
Re: Python-generated diagram as "external material"
John Kwrites: > OK I tried this. I defined a new Python file format with extension .py in Lyx, and then created a Python -> PDF > (pdflatex) converter that runs the command: > > python $$i $$o > > But when I try exporting the document to PDF I get the following error: > > "No information for converting python format files to png. Define a converter in the preferences." > > Why is it trying to convert to PNG? > > J What you did seems all correct. I don't know what the problem might be, because as far as I know PDF should be used for output and PNG used only to display the image within the LyX window. Perhaps someone else has more experience with this. -- Julien
RE: Python-generated diagram as external material
John K wrote: I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. This isn't critical, it merely means you won't get a preview within LyX because of a failure to convert to something displayable. (png, I believe.) Of course, this may also be a symptom of what's wrong with the main conversion. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) That is the problem, and I guess it explains why everything else goes wrong too. First thing to check: is python in the path? I.e. can you give the command python filename.py on the command line - will that work? If python isn't in the path, then LyX won't find it. Yes, Python is on the path. I tried putting the full path to Python in the UpdateCommand as well but that didn't work either. I don't think it's a path issue because even a command like echo test output.txt does not work. If this succeed, will the latex export then work, as long as the manually converted file is present? If I first run the Python script manually and then try exporting the Lyx document to PDF (pdflatex), I still get this error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. However, if I export to LaTeX (pdflatex), and then open this LaTeX file in TeXnicCenter, I can export to PDF with no problems and the Python-generated figure shows up correctly. Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. Another wild guess: You have a path with spaces in it, e.g. Documents and Settings. Some versions of LyX can't deal with that. Some can, but you have to take care when a path is passed to external utilities (such as python) Otherwise, you risk that: python C:\documents and settings\folder\file.py becomes python C:\documents and settings\folder\file.py and the latter just won't work. To check if you have space problems, copy the document and all files to some space-free path such as C:\test\ See if that changes anything. I tried putting everything in to the root directory C:\ but had the same problem. J _ Link all your email accounts and social updates with Hotmail. Find out now. http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G
RE: Python-generated diagram as external material
John K wrote: I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. This isn't critical, it merely means you won't get a preview within LyX because of a failure to convert to something displayable. (png, I believe.) Of course, this may also be a symptom of what's wrong with the main conversion. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) That is the problem, and I guess it explains why everything else goes wrong too. First thing to check: is python in the path? I.e. can you give the command python filename.py on the command line - will that work? If python isn't in the path, then LyX won't find it. Yes, Python is on the path. I tried putting the full path to Python in the UpdateCommand as well but that didn't work either. I don't think it's a path issue because even a command like echo test output.txt does not work. If this succeed, will the latex export then work, as long as the manually converted file is present? If I first run the Python script manually and then try exporting the Lyx document to PDF (pdflatex), I still get this error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. However, if I export to LaTeX (pdflatex), and then open this LaTeX file in TeXnicCenter, I can export to PDF with no problems and the Python-generated figure shows up correctly. Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. Another wild guess: You have a path with spaces in it, e.g. Documents and Settings. Some versions of LyX can't deal with that. Some can, but you have to take care when a path is passed to external utilities (such as python) Otherwise, you risk that: python C:\documents and settings\folder\file.py becomes python C:\documents and settings\folder\file.py and the latter just won't work. To check if you have space problems, copy the document and all files to some space-free path such as C:\test\ See if that changes anything. I tried putting everything in to the root directory C:\ but had the same problem. J _ Link all your email accounts and social updates with Hotmail. Find out now. http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G
RE: Python-generated diagram as "external material"
> John K wrote: >> >> >> I am trying to auto-generate a diagram from a Python script in my Lyx >> document using the "External Material" function. I have created a Python >> script called "myscript.py" which generates a diagram and saves it to >> "myscript.pdf". I am trying to make Lyx run my script to generate the >> diagram when I export my document to PDF. >> >> I added the following to the Lyx external_templates file: >> >> Template Python >> GuiName "Python: $$AbsOrRelPathParent$$Basename" >> HelpText >> Python diagram. >> HelpTextEnd >> InputFormat "*" >> FileFilter "*.py" >> AutomaticProduction true >> Preview Graphics >> Format PDFLaTeX >> Product "\\includegraphics{$$AbsPath$$Basename.pdf}" >> Requirement "graphicx" >> UpdateCommand "python $$AbsPath$$Basename.py" >> UpdateFormat pdf >> UpdateResult "$$AbsPath$$Basename.pdf" >> Requirement "graphicx" >> ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" >> FormatEnd >> TemplateEnd >> >> However, when I insert the Python script in Lyx, it draws a box that says >> "Error converting to loadable format". > This isn't critical, it merely means you won't get a preview within LyX > because of a failure to convert to something displayable. (png, I believe.) > > Of course, this may also be a symptom of what's wrong with the main > conversion. > >> If I try exporting to PDF using pdflatex, I get the following error: >> >> "Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math >> symbol since I think you left one out. Proceed, with fingers crossed." >> >> If I export to Latex using pdflatex, it seems to export correctly, and my >> text file contains something like this: >> >> begin{document} >> \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} >> \end{document} >> >> However, it doesn't run my update command, i.e. doesn't run the Python >> script. (I've even tried changing my update command to things like "echo >> test> output.txt" but I can't seem to get any commands to run at all.) >> > That is the problem, and I guess it explains why everything else goes > wrong too. > > First thing to check: is python in the path? I.e. can you give the > command "python filename.py" on the command line - will that work? > > If python isn't in the path, then LyX won't find it. Yes, Python is on the path. I tried putting the full path to Python in the UpdateCommand as well but that didn't work either. I don't think it's a path issue because even a command like "echo test> output.txt" does not work. > If this succeed, will the latex export then work, as long as the > manually converted file is present? If I first run the Python script manually and then try exporting the Lyx document to PDF (pdflatex), I still get this error: "Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed." However, if I export to LaTeX (pdflatex), and then open this LaTeX file in TeXnicCenter, I can export to PDF with no problems and the Python-generated figure shows up correctly. >> Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on >> Windows XP. > > Another wild guess: You have a path with spaces in it, e.g. "Documents > and Settings". Some versions of LyX can't deal with that. Some can, but > you have to take care when a path is passed to external utilities (such > as python) Otherwise, you risk that: > > python "C:\documents and settings\folder\file.py" > becomes > python "C:\documents" "and" "settings\folder\file.py" > and the latter just won't work. > > To check if you have space problems, copy the document and all files > to some space-free path such as C:\test\ > See if that changes anything. I tried putting everything in to the root directory C:\ but had the same problem. J _ Link all your email accounts and social updates with Hotmail. Find out now. http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G
RE: Python-generated diagram as external material
> John K writes: >> I added the following to the Lyx external_templates file: >> >> Template Python >> GuiName "Python: $$AbsOrRelPathParent$$Basename" >> HelpText >> Python diagram. >> HelpTextEnd >> InputFormat "*" > > I think you need to define an input format and a .py -> .pdf converter which > runs the python interpreter on your file. > >> FileFilter "*.py" >> AutomaticProduction true >> Preview Graphics >> Format PDFLaTeX >> Product "\\includegraphics{$$AbsPath$$Basename.pdf}" >> Requirement "graphicx" >> UpdateCommand "python $$AbsPath$$Basename.py" > > I haven't seen any description for "UpdateCommand" anywhere. Where does that > come from? It's not in the documentation, or? I saw it in another posting to this list, and there's a few other similar examples that use it on the web: http://www.google.com.au/#hl=en=lyx+%2BUpdateCommand >> UpdateFormat pdf >> UpdateResult "$$AbsPath$$Basename.pdf" >> Requirement "graphicx" >> ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" >> FormatEnd >> TemplateEnd >> >> However, when I insert the Python script in Lyx, it draws a box that says > "Error converting to loadable >> format". > > Yes, because LyX doesn't know how to convert a python file to a graphics file. > Try the way I described above: defining the file format and converter under > the > menu : Tools> Preferences...> File Handling. I can define a new Python file format, but strangely, no matter what I do the "Add" button in the converters section is greyed out. I can only create the converter by editing and saving over an existing converter in the list. > Once you have that I believe it will work. In fact once you have that you > could > simply use the graphics inset in the usual way to insert your .py file, that > is, > no need for an external material template. Makes sense, but then what are the external material templates actually meant to be used for? J _ Get the latest jobs delivered. Sign up for SEEK Jobmail. http://clk.atdmt.com/NMN/go/157639755/direct/01/
Re: Python-generated diagram as external material
On 2010-03-11, John K wrote: >> I think you need to define an input format and a .py -> .pdf converter which >> runs the python interpreter on your file. This is an alternative way to the "external inset". ... >> Try the way I described above: defining the file format and converter >> under the menu : Tools> Preferences...> File Handling. > I can define a new Python file format, but strangely, no matter what I > do the "Add" button in the converters section is greyed out. I can only > create the converter by editing and saving over an existing converter > in the list. The UI is somewhat strange in this area. You can modify an existing converter + its input/output formats and it will be saved as a new converter. Consider a name more specific than Python as input format description, as there could be also Python scripts requiring other processing or resulting in a different output format. >> Once you have that I believe it will work. In fact once you have that >> you could simply use the graphics inset in the usual way to insert >> your .py file, that is, no need for an external material template. > Makes sense, but then what are the external material templates actually > meant to be used for? There is external material that does not fit in the converter tool paradiga. Also, with 'external inset' you can specify parameters in the LyX document. If these are not needed, defining a Converter is simpler and enables a preview. Günter
Python-generated diagram as external material
I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. J _ Get the latest jobs delivered. Sign up for SEEK Jobmail. http://clk.atdmt.com/NMN/go/157639755/direct/01/
Re: Python-generated diagram as external material
John K wrote: I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. This isn't critical, it merely means you won't get a preview within LyX because of a failure to convert to something displayable. (png, I believe.) Of course, this may also be a symptom of what's wrong with the main conversion. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) That is the problem, and I guess it explains why everything else goes wrong too. First thing to check: is python in the path? I.e. can you give the command python filename.py on the command line - will that work? If python isn't in the path, then LyX won't find it. If this succeed, will the latex export then work, as long as the manually converted file is present? Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. Another wild guess: You have a path with spaces in it, e.g. Documents and Settings. Some versions of LyX can't deal with that. Some can, but you have to take care when a path is passed to external utilities (such as python) Otherwise, you risk that: python C:\documents and settings\folder\file.py becomes python C:\documents and settings\folder\file.py and the latter just won't work. To check if you have space problems, copy the document and all files to some space-free path such as C:\test\ See if that changes anything. Helge Hafting
Python-generated diagram as external material
I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. J _ Get the latest jobs delivered. Sign up for SEEK Jobmail. http://clk.atdmt.com/NMN/go/157639755/direct/01/
Re: Python-generated diagram as external material
John K wrote: I am trying to auto-generate a diagram from a Python script in my Lyx document using the External Material function. I have created a Python script called myscript.py which generates a diagram and saves it to myscript.pdf. I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName Python: $$AbsOrRelPathParent$$Basename HelpText Python diagram. HelpTextEnd InputFormat * FileFilter *.py AutomaticProduction true Preview Graphics Format PDFLaTeX Product \\includegraphics{$$AbsPath$$Basename.pdf} Requirement graphicx UpdateCommand python $$AbsPath$$Basename.py UpdateFormat pdf UpdateResult $$AbsPath$$Basename.pdf Requirement graphicx ReferencedFile pdflatex $$AbsPath$$Basename.pdf FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says Error converting to loadable format. This isn't critical, it merely means you won't get a preview within LyX because of a failure to convert to something displayable. (png, I believe.) Of course, this may also be a symptom of what's wrong with the main conversion. If I try exporting to PDF using pdflatex, I get the following error: Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like echo test output.txt but I can't seem to get any commands to run at all.) That is the problem, and I guess it explains why everything else goes wrong too. First thing to check: is python in the path? I.e. can you give the command python filename.py on the command line - will that work? If python isn't in the path, then LyX won't find it. If this succeed, will the latex export then work, as long as the manually converted file is present? Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. Another wild guess: You have a path with spaces in it, e.g. Documents and Settings. Some versions of LyX can't deal with that. Some can, but you have to take care when a path is passed to external utilities (such as python) Otherwise, you risk that: python C:\documents and settings\folder\file.py becomes python C:\documents and settings\folder\file.py and the latter just won't work. To check if you have space problems, copy the document and all files to some space-free path such as C:\test\ See if that changes anything. Helge Hafting
Python-generated diagram as "external material"
I am trying to auto-generate a diagram from a Python script in my Lyx document using the "External Material" function. I have created a Python script called "myscript.py" which generates a diagram and saves it to "myscript.pdf". I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName "Python: $$AbsOrRelPathParent$$Basename" HelpText Python diagram. HelpTextEnd InputFormat "*" FileFilter "*.py" AutomaticProduction true Preview Graphics Format PDFLaTeX Product "\\includegraphics{$$AbsPath$$Basename.pdf}" Requirement "graphicx" UpdateCommand "python $$AbsPath$$Basename.py" UpdateFormat pdf UpdateResult "$$AbsPath$$Basename.pdf" Requirement "graphicx" ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says "Error converting to loadable format". If I try exporting to PDF using pdflatex, I get the following error: "Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed." If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like "echo test> output.txt" but I can't seem to get any commands to run at all.) Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. J _ Get the latest jobs delivered. Sign up for SEEK Jobmail. http://clk.atdmt.com/NMN/go/157639755/direct/01/
Re: Python-generated diagram as "external material"
John K wrote: I am trying to auto-generate a diagram from a Python script in my Lyx document using the "External Material" function. I have created a Python script called "myscript.py" which generates a diagram and saves it to "myscript.pdf". I am trying to make Lyx run my script to generate the diagram when I export my document to PDF. I added the following to the Lyx external_templates file: Template Python GuiName "Python: $$AbsOrRelPathParent$$Basename" HelpText Python diagram. HelpTextEnd InputFormat "*" FileFilter "*.py" AutomaticProduction true Preview Graphics Format PDFLaTeX Product "\\includegraphics{$$AbsPath$$Basename.pdf}" Requirement "graphicx" UpdateCommand "python $$AbsPath$$Basename.py" UpdateFormat pdf UpdateResult "$$AbsPath$$Basename.pdf" Requirement "graphicx" ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" FormatEnd TemplateEnd However, when I insert the Python script in Lyx, it draws a box that says "Error converting to loadable format". This isn't critical, it merely means you won't get a preview within LyX because of a failure to convert to something displayable. (png, I believe.) Of course, this may also be a symptom of what's wrong with the main conversion. If I try exporting to PDF using pdflatex, I get the following error: "Missing $ inserted. Missing { inserted. I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed." If I export to Latex using pdflatex, it seems to export correctly, and my text file contains something like this: begin{document} \includegraphics{C:/Documents and Settings/MyUsername/Desktop/myscript.pdf} \end{document} However, it doesn't run my update command, i.e. doesn't run the Python script. (I've even tried changing my update command to things like "echo test> output.txt" but I can't seem to get any commands to run at all.) That is the problem, and I guess it explains why everything else goes wrong too. First thing to check: is python in the path? I.e. can you give the command "python filename.py" on the command line - will that work? If python isn't in the path, then LyX won't find it. If this succeed, will the latex export then work, as long as the manually converted file is present? Any ideas what I am doing wrong? I've tried on Lyx 1.6.3 and 1.6.5-1 on Windows XP. Another wild guess: You have a path with spaces in it, e.g. "Documents and Settings". Some versions of LyX can't deal with that. Some can, but you have to take care when a path is passed to external utilities (such as python) Otherwise, you risk that: python "C:\documents and settings\folder\file.py" becomes python "C:\documents" "and" "settings\folder\file.py" and the latter just won't work. To check if you have space problems, copy the document and all files to some space-free path such as C:\test\ See if that changes anything. Helge Hafting
Re: Python-generated diagram as external material
John Kwrites: > I added the following to the Lyx external_templates file: > > Template Python > GuiName "Python: $$AbsOrRelPathParent$$Basename" > HelpText > Python diagram. > HelpTextEnd > InputFormat "*" I think you need to define an input format and a .py -> .pdf converter which runs the python interpreter on your file. > FileFilter "*.py" > AutomaticProduction true > Preview Graphics > Format PDFLaTeX > Product "\\includegraphics{$$AbsPath$$Basename.pdf}" > Requirement "graphicx" > UpdateCommand "python $$AbsPath$$Basename.py" I haven't seen any description for "UpdateCommand" anywhere. Where does that come from? It's not in the documentation, or? > UpdateFormat pdf > UpdateResult "$$AbsPath$$Basename.pdf" > Requirement "graphicx" > ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" > FormatEnd > TemplateEnd > > However, when I insert the Python script in Lyx, it draws a box that says "Error converting to loadable > format". Yes, because LyX doesn't know how to convert a python file to a graphics file. Try the way I described above: defining the file format and converter under the menu : Tools > Preferences... > File Handling. Once you have that I believe it will work. In fact once you have that you could simply use the graphics inset in the usual way to insert your .py file, that is, no need for an external material template. -- Julien