0

Code:

import pylatex as pl
#import latexmk

doc = pl.Document()
doc.append(pl.Math(data=['x^2+3x+1']))
path = r"C:/Users/maach/OneDrive/Documents/Python Scripts/mathfile"
doc.generate_pdf(clean_tex=False,compiler=r'C:/Users/maach/anaconda3/pkgs/latexmk-4.76-h57928b3_0\Scripts', filepath = path)

Spyder Kernel:

runfile('C:/Users/maach/OneDrive/Documents/Python Scripts/untitled1.py', wdir='C:/Users/maach/OneDrive/Documents/Python Scripts') Traceback (most recent call last):

File ~\OneDrive\Documents\Python Scripts\untitled1.py:7 in doc.generate_pdf(clean_tex=False,compiler=r'C:/Users/maach/anaconda3/pkgs/latexmk-4.76-h57928b3_0\Scripts', filepath = path)

File ~\anaconda3\lib\site-packages\pylatex\document.py:250 in generate_pdf output = subprocess.check_output(command,

File ~\anaconda3\lib\subprocess.py:424 in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,

File ~\anaconda3\lib\subprocess.py:505 in run with Popen(*popenargs, **kwargs) as process:

File ~\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py:108 in init super(SubprocessPopen, self).init(*args, **kwargs)

File ~\anaconda3\lib\subprocess.py:951 in init self._execute_child(args, executable, preexec_fn, close_fds,

File ~\anaconda3\lib\subprocess.py:1420 in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

PermissionError: [WinError 5] Access is denied

Perl is installed in Anaconda environments. I've tried updating pip and running Spyder as administrator. Full permissions allowed on the folder containing latexmk and the target directory. Have not seen any other questions asked like this on any programming website. How do I fix this error?

  • Can you simplify it by removing unnecessary steps and breaking it down? For example, try running a simple process in Python using `process.check_output()`, or writing the output file using simple Python commands, to ascertain whether it's an operating system issue, or if it specific to LaTeX/pylatex. – Vercingatorix Jul 03 '23 at 19:16
  • Spyder has no problem with creating text files for IO, and creating pdfs with reportlab. I believe the problem is caused by the ide trying to directly access the latexmk script file through the pylatex library. I tried using pylatex in PyCharm and selected pdflatex as the latex compiler, resulting in the same error message. At this point I am fairly confident that this is a pylatex problem so I'm not sure how to proceed here. Can you suggest any alternatives? I am trying to generate a pdf with latex formatted sympy expressions. – ASD Researcher Jul 04 '23 at 17:20

0 Answers0