0

I would like to use PythonTex in Lyx on a Mac. I don't understand the intricacy of Lyx/Tex etc. I think I managed to install PythonLex by installing MacTex 2021 which also installed Tex Live Utility and if I use it to look at packages it also installed pythonlex.

I found this question StackExchange Question

Not sure how I enter the \xxxx statements into a document so tried

Document | Setting | Latex Preamble

And pasted info from article.

When I tried to display the PDF I found it did not like the first two lines with inputenc and fontenc

What it displayed was enter image description here

I would like to be able to enter matplotlib python into my document that display plots & charts, Please advise

19
  • Hello, first, you should always endeavour to put in an Minimal compilable example of your issue for others to test. Your issue is very general, so I try to help, but as of now only in general way. First things first -- pythontex in a script file pythontex.py ; which should be locatable in your terminal. Are you able to find executable file pythontex in your $PATH? I am not familiar with LyX, but your error apell that you havent run pythontex on your file. If you want to use pythontex, you have to run latex compiler, then pythontex, then again latex compiler to get the results. Aug 5 '21 at 7:38
  • Example is as per the linked StackExchanged Question. I just tried unsuccessfully to do the same. If I go to a command line console then I get keithsloan@Keiths-iMac GDML % pythontex Traceback (most recent call last): File "/Library/TeX/texbin/pythontex", line 50, in <module> import pythontex2 as pythontex File "/usr/local/texlive/2021/texmf-dist/scripts/pythontex/pythontex2.py", line 61, in <module> from pygments.styles import get_all_styles ImportError: No module named pygments.styles Aug 5 '21 at 12:06
  • In TexLog I see No file pythontex-files-TestPythonTex-A/TestPythonTex-A.pytxmcr. Run PythonTeX to create it. Package newfloat Info: New float listing' with options fileext=lopytx' on inp ut line 20. \c@listing=\count288 \newfloat@ftype=\count289 Package newfloat Info: float type `listing'=8 on input line 20. (/usr/local/texlive/2021/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] Aug 5 '21 at 12:11
  • From those errors seems that you dont have pygments python package installed. Have you ever installed pygments with pip? Aug 5 '21 at 12:12
  • I have not, but I suspect it might have been installed as part of Mac Tex 2021 as if I try pip3 install pygments it tells me the requirement is already satisfied Aug 5 '21 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.