1

I'm using pymatgen, which has a class BaderAnalysis (https://github.com/materialsproject/pymatgen/blob/v2020.4.29/pymatgen/command_line/bader_caller.py). This class needs a executable called bader (binary from another source), so it checks if the file is there or not using which(). I do have the file and i can run the bader program manually, but I always get the error that the file isn't there. If I try the which() command manually it turns out that it only finds it with the prefix ./

print(which('bader'))
print(which('./bader'))

Output: None

./bader

How can I make it in a way that the which command finds it without the prefix? (because the pymatgen class literally runs if not which("bader") or which("bader.exe"): 'error message...' when initializing the class.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
ramobal
  • 241
  • 2
  • 9
  • 1
    which only searches based on the env PATH. Try running the command from a shell in another directory. You'll see that the exe is not found. The ./ adds the current working directory to the path temporarily – WombatPM May 08 '20 at 23:58

1 Answers1

1

You would need to add your current directory to your PATH environment variable. You can do it in your program invocation. E.g.,

PATH=$PATH:$PWD python my_script.py
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45