On 15May2019 08:16, Stephen P. Molnar <s.mol...@sbcglobal.net> wrote:
I am writing scripts to semi-automate some of my Quantum Chemistry software and have encountered a problem that has me baffled. The two scripts have the same form, the only difference being the commands.

As you say, the scripts are the same but for that tiny difference. So let's look:

for nvar in ligand:
   command = ["./pythonsh", "./prepare_ligand4.py",
[...]
   command = ["./pythonsh", "./prepare_pdf4.py",
[...]
The errors are:

runfile('/home/comp/Apps/Models/1-NerveAgents/Ligands/calc_pdf.py', wdir='/home/comp/Apps/Models/1-NerveAgents/Ligands')
b''
None
/sdc1/Apps/MGLTools2-1.1/bin/python: can't open file './prepare_pdf4.py': [Errno 2] No such file or directory

So: first issue: your prepare_pdf4.py file is missing. Is it really missing or are you in the wrong working directory? Might its filename be mistyped?

BTW, you shouldn't need the leading "./" on the .py filenames: harmless but also useless. If you copied that usage from the "./pythonsh" incantation, the circumstances are different. You probably need the "./pythonsh" to execute it directly from the current directory, which is not in your $PATH (and indeed it should not be - that way lies subversion). The .py files are just data and do not need this.

Then, the second part. This is a totally separate error from your script. Jumping to the bottom...

Traceback (most recent call last):
[...]
File "/home/comp/Apps/Models/1-NerveAgents/Ligands/calc_pdf.py", line 23, in <module>
   print ('Subprocess FAILED:', proc.command)

AttributeError: 'Popen' object has no attribute 'command'

Because the prepare_pdf.py file is missing, for whatever reason, your "if proc.returncode" fire. And in that code you access "proc.command", which isn't defined. In the former script it doesn't try to execute this line because pythonsh succeeded.

Looking at the subprocess docs, I think that is spelled "cmd", not "command".

I have attached the two scripts that are called and a test input file.

This is a text only list. Attachments are dropped before your message goes out. Fortunately you have enough information in the main body of the message.

Googling has not helped me to find a solution [...]

1: I recommend duckduckgo instead of Google for privacy/tracking reasons.

2: When I search, I tend to find people with the same problem, not necessarily people with answers. But this question might be hard to get good hits on because the problem lies in a spelling error, which others may not have made that way.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to