问题描述
我在模块上发现了一些问题,但更常见的问题似乎是我认为我已经管理的参数列表正确(最终)
I've found a few questions on the module but the more common problem seems to be getting the argument list right which I think I have managed (eventually)
我正在尝试运行一个程序,该程序需要在命令行中输入这样的输入,
I am trying to run a program that expects an input like this in the command line,
fits2ndf in out
'in' 是要转换的文件的文件路径,'out' 是保存结果的路径和文件名.
with 'in' being the filepath of the file to be converted and 'out' being the path and filename to save the result to.
所以使用子进程,
subprocess.call(["fits2ndf","/media/tom_hdd/Transfer/reference.fits","/media/tom_hdd/Transfer/reference.sdf"])
这引发了,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
设置 shell=TRUE
(我知道这是不好的)会产生相同的结果.不确定它是否相关,但我正在使用 tcsh.有什么建议吗?
Setting shell=TRUE
(which I know is bad) produces the same result. Not sure if it is relevant but I am using tcsh. Any suggestions?
根据问题进行编辑
我没有永久设置 PATH,但是 fits2ndf
是我使用初始化的程序包的一部分
I haven't permanently set the PATH however fits2ndf
is part of a package of programs which I initialize using
% tcsh
% setenv STARLINK_DIR /home/tomq/star-kapuahi
% source $STARLINK_DIR/etc/login
% source $STARLINK_DIR/etc/cshrc
并且通常在任何目录中都可以在不指定完整路径的情况下工作.
and normally works from within any directory without specifying the full path.
推荐答案
whichfits2ndf
会告诉你fits2ndf的路径.
which fits2ndf
will show you the path of fits2ndf.
之后,您可以编写代码的完整路径,它应该可以工作.
After that you can write given full path to your code and it should work.
例如:
~$ which mv
/bin/mv
我的python代码:
My python code:
import subprocess
subprocess.call(["/bin/mv","/tmp/a","/tmp/b"])
这篇关于python subprocess.call() “没有这样的文件或目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!