I cannot get PythonTex to fully work with TexStudio. I'm having a nightmare with this and solved many issues, including activating the conda base, mkl-service library clashes, and TexStudio command paths. My environment variables also needed to be fixed to include the Anaconda library binaries in the search path. The remaining issue I cannot solve after two days is generating plots through PythonTex. The error appears as: "This application failed to start because it could not find or load Qt platform plugin"windows". A native Windows cmd has the same problem so I do not think PythonTex is at fault. I think the problem is with importing libraries outside of the python core into TexStudio.
Here is a MWE
\documentclass{article}
\usepackage{pythontex}
\begin{document}
\begin{pycode}
import sys
print(sys.version)
\end{pycode}
\end{document}
This prints: 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Here is a nonworking example
\documentclass{article}
\usepackage{pythontex}
\begin{document}
\begin{pylabblock}
rc('text', usetex=True)
rc('font', family='serif')
rc('font', size=10.0)
rc('legend', fontsize=10.0)
rc('font', weight='normal')
x = linspace(0, 10)
figure(figsize=(4, 2.5))
plot(x, sin(x), label='$\sin(x)$')
xlabel(r'$x\mathrm{-axis}$')
ylabel(r'$y\mathrm{-axis}$')
legend(loc='lower right')
savefig('myplot.pdf', bbox_inches='tight')
\end{pylabblock}
\end{document}
I have done the following to try and rectify the problem:
- Activated conda base
- Did
conda install mkl-service
- Tried piping conda activation as per this question
- Verified that there is no clash of MKL libraries using
where libiomp5md.dll
as indicated here and here - Verified the python code in Spyder and in the native cmd prompt
- Tried adding the QT_PLUGIN_PATH environment variable
Unfortunately, the solution here has not worked for me either. Any help much appreciated.
System:
- Windows10
- TexStudio 2.12.6
- Conda 4.8.2
- PythonTex 0.17
Anaconda
distribution and use pure python (and install packages withpip
). I found no benefit for using Anaconda over python itself ... You example works for my setting on Win10, TeXworks in TeXlive2019, python 3.8 64bit and PythonTeX 0.17conda
before, but needed pymc3 which is a nightmare of dependencies - the great strength ofconda
. Shouldn't this just work?!pymc3
, I am using almost all its listed dependencies (except forTheano
) and I have no problem. For me is a surprise, that you have to set-up an envinment variable (?connected toqt
?) to make work a machine learning module. Doesnt seem right. I dare to say thatconda
has its own problems with dependencies managing, think I read somewhere it has trouble to keep up.