pyXDSM icon indicating copy to clipboard operation
pyXDSM copied to clipboard

Better error messages and documentation for dependencies

Open FranseFrikandel opened this issue 2 years ago • 3 comments

Description of the issue

So, as a user of Overleaf, and thus not having a local LaTeX distribution installed, the first time trying to use this package didn't work. I found it out quite quickly by taking a quick peak in the sourcecode, however the package documentation doesn't appear to really mention the requirements of having a LaTeX distribution installed, and the error you get is a very undescriptive FileNotFoundError with nothing pointing to what exact file it is missing.

The error message I got:

Traceback (most recent call last):
  File "C:\Users\username\path\to\file.py", line 200, in <module>
    x.write("xdsm", cleanup=True, quiet=True)
  File "C:\Python310\lib\site-packages\pyxdsm\XDSM.py", line 628, in write 
    subprocess.run(command, check=True)
  File "C:\Python310\lib\subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified 

Potential solution

Solving the issue would be two-fold. Firstly, the error message should be more descriptive. An error message saying pdfLaTeX wasent found would be a lot more helpful.

Secondly, the "installation" documentation should mention a LaTeX environment is required for proper operation.

I would be happy to look into making a PR for this if this would be desired.

FranseFrikandel avatar Nov 26 '22 19:11 FranseFrikandel

I agree that the error message is not very helpful. My proposed solution would be to use something like shutil.which to check if pdflatex is on the $PATH, and throw an error instead of trying to execute the command using subprocess.run. Also note that while a conda package exists, Windows builds are not tested either here or in the feedstock repo.

The documentation does in fact mention requiring a LaTeX installation, however the documentation can certainly be improved. We do welcome PRs to our packages if you're interested.

I also want to point out that there is the possibility of outputting a .tex file without compiling to PDF using pdflatex, by passing in the option build=false. This generates only the .tex file which can then be included in your LaTeX source file and compiled together.

ewu63 avatar Dec 02 '22 20:12 ewu63

Hi, sorry for intruding in the conversation, but I'm experimenting the same error @FranseFrikandel posted, and I couldn't get how to solve it. I tried to install pdf latex, but it's still happening, I don't know if I need to install LaTeX also or how to obtain the .tex and from the .tex get the PDF

Thanks and sorry for the intrusion

Mr-PDM avatar Dec 08 '23 17:12 Mr-PDM

Hi @Mr-PDM ,

I'm going to assume you run Windows. Have you tried running the pdflatex command from within powershell to see if that works? If it doesn't, you'll likely need to include it in your path variable if it is indeed installed. Personally I have MikTeX installed which includes pdflatex, and AFAIK it should set your path variable correctly.

Essentially, you should be able to get pdflatex command to work in your terminal, and it should also resolve this issue.

The option mentioned earlier, where only the .tex file is generated is of course also still an option. It shouldn't require pdflatex, however you'll have to compile the latex file into a PDF yourself. Shouldn't be an issue if you've ever worked with LaTeX before in for example Overleaf.

FranseFrikandel avatar Dec 08 '23 18:12 FranseFrikandel