My question : How come PythonTex works as long as I don't try to load numpy ?
In the simple code below for instance
MWE
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{float}
\usepackage{pythontex}
\begin{document}
\begin{pycode}
def fib(n): # nth Fibonacci value
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a
\end{pycode}
Did you know that $F_{10} = \py{fib(10)}$?
Did you know that $F_{100} = \py{fib(100)}$?
\end{document}
gives
whereas I get
When I use
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{float}
\usepackage{pythontex}
\begin{document}
\begin{pycode}
%import numpy as np %<- I get an error each time I try to load numpy
def fib(n): # nth Fibonacci value
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a
\end{pycode}
Did you know that $F_{10} = \py{fib(10)}$?
Did you know that $F_{100} = \py{fib(100)}$?
\end{document}
I compile on Windows 10, TeXmaker, MikteX, Anaconda and run
pdflatex --shell-escape -synctex=1 -interaction=nonstopmode %.tex|
python "C:/Program Files/MiKTeX/scripts/pythontex/pythontex.py" %.tex|
pdflatex --shell-escape -synctex=1 -interaction=nonstopmode %.tex
Reading multiple posts on PythonTeX I understand the answer might be related to my MikTeX and/or Python installation? But strange it works for simple things and creates an error for numpy...
Edit
As mentionned in comment, there might be a problem to find python.tex. So I inputed the full path to python.exe directly in cmd but I get the following error message you might understand better than I do :/




where pythonand bingo You're right. I get two entries :/ Especially aAppData\Local\Microsoft\WindowsApps\python.exeI was not aware of !! – JeT Dec 13 '20 at 22:45pdflatex --shell-escape -synctex=1 -interaction=nonstopmode %.tex| C:\tools\Anaconda3\python.exe "C:/Program Files/MiKTeX/scripts/pythontex/pythontex.py" %.tex| pdflatex --shell-escape -synctex=1 -interaction=nonstopmode %.texbut I still get an error. – JeT Dec 13 '20 at 22:55