Minted package error: -shell-escape flag not set in LaTeX

3 replies · 3K views · last reply
member 428835
Hi PF!

I am trying to import code written in Python into Latex via the "minted" package. However, I am getting the error:

Package minted error: you must invoke latex with the -shell-escape flag.

I tried googling help but I can't figure it out. I'm using Python 2.7 on mac OSX sierra. Any help is greatly appreciated!
 
If I understand you correctly, you want to show your Python code in [itex]\LaTeX[/itex] as shown below?

I am not familiar with the minted package you mention, but if you are open to other suggestions I'll tell you what I do: When I have to include e.q. Python code in [itex]\LaTeX[/itex] I use the code found here: https://www.quora.com/What-is-the-optimal-way-to-include-Python-code-in-a-LaTeX-document

If you want other colors for let's say the print function, you can easily customize it to fit your needs at the start of the code. Let me know if you need any help using the code.
Screenshot of a Python script with numbered lines, syntax-highlighted in a LaTeX-typeset style, showing code for reading FITS data, generating valid data, polynomial fitting, and computing eigenvectors, page number 10.
 
Last edited by a moderator:
Thanks for the suggestion. I tried it out, but is was getting very monochromatic code. I'm quite sold on minted if I could just get the darn thing to work.
 
Looks like it's working fine. I just had to run it from Terminal as
$ pdflatex -shell-escape hw2
Thanks for your insight!
 
  • Like
Likes   Reactions: vanhees71 and Baarken