python subprocess.call() “没有这样的文件或目录"

python subprocess.call() quot;no such file or directoryquot;(python subprocess.call() “没有这样的文件或目录)
本文介绍了python subprocess.call() “没有这样的文件或目录"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模块上发现了一些问题,但更常见的问题似乎是我认为我已经管理的参数列表正确(最终)

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() “没有这样的文件或目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Leetcode 234: Palindrome LinkedList(Leetcode 234:回文链接列表)
How do I read an Excel file directly from Dropbox#39;s API using pandas.read_excel()?(如何使用PANDAS.READ_EXCEL()直接从Dropbox的API读取Excel文件?)
subprocess.Popen tries to write to nonexistent pipe(子进程。打开尝试写入不存在的管道)
I want to realize Popen-code from Windows to Linux:(我想实现从Windows到Linux的POpen-code:)
Reading stdout from a subprocess in real time(实时读取子进程中的标准输出)
How to call type safely on a random file in Python?(如何在Python中安全地调用随机文件上的类型?)