I would like to use Pythontex. I am on Mac texlive2019, python 3.7 (anaconda) TeXShop V 4.31 I followed all that was written on the documentation for the installation but impossible to have the result 😭




import math
def racine(a):
    return math.sqrt(a)
Résultat : 
import math
def racine(a):
    return math.sqrt(a)
var = 1 + 1
  • What does echo $PATH return in Terminal? – Herb Schulz Aug 4 '19 at 15:38

Please download the file Pythontex-platexmkrc.zip from https://herbs.github.io and unzip it. That produces a platexmkrc file that contains information for TeXShop's pdflatexmk engine on how to process the files created by pythontex. Place that file in the same folder as your Source file. Then add the line % !TEX program = pdflatexmk to the top of your source file (it tells TeXShop to use the pdflatexmk engine to typeset the file) and typeset the file using Typeset->Typeset (Cmd-T).

NOTE: PLEASE READ THE NOTE BELOW. It is necessary to make a change to the platexmkrc file to work with anaconda3.

| improve this answer | |
  • Sigh... There is one line in the platexmkrc file that will need editing. Drop the platexmkrc file on the TeXShop icon to open it for editing in TeXShop. Change anacond2 to anaconda3 and save it. – Herb Schulz Aug 4 '19 at 16:54
  • I do it and I have this message:Running 'pythontex --interpreter python:/anaconda3/bin/python "testpytex.pytxcode"' ------------ === TeX engine is 'pdfTeX' Latexmk: applying rule 'pythontex testpytex'... Traceback (most recent call last): File "/Library/TeX/texbin/pythontex", line 50, in <module> import pythontex2 as pythontex File "/usr/local/texlive/2019/texmf-dist/scripts/pythontex/pythontex2.py", line 61, in <module> from pygments.styles import get_all_styles ImportError: No module named pygments.styles – habib Aug 5 '19 at 10:26
  • Did you install the full anaconda3? I believe that pygments comes with that distribution. Do you have an Anaconda-Navigator app in /Applications? If so, open it and look under Environments for pygments. check it if it isn't already checked. – Herb Schulz Aug 5 '19 at 11:52
  • yes I have it , I don't know what to do ? – habib Aug 5 '19 at 14:16
  • Please try to run the command sudo /usr/local/bin/easy_install Pygments in Terminal. It will ask for your admin password. This installs another version of Pygments where it might be found more easily. – Herb Schulz Aug 5 '19 at 16:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.