Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python subprocess.Popen[Errno 2]没有这样的文件或目录_Python_Subprocess - Fatal编程技术网

Python subprocess.Popen[Errno 2]没有这样的文件或目录

Python subprocess.Popen[Errno 2]没有这样的文件或目录,python,subprocess,Python,Subprocess,我在流中使用的几个脚本上工作。我做了一些,现在我尝试做一个集中所有脚本的启动器 我认为我在子流程方面做得很好,但我有一些困难 我尝试使用以下行启动脚本: subprocess.Popen(['python', "E:/path/rocksmith/rocksmith.pyw"], shell=True) 但是python给了我一个没有这样的文件或目录错误的提示。 在我想要启动的脚本(rocksmith.pyw)中,我用open()打开了一些文本文件,我猜python找不到.txt文件,因为.t

我在流中使用的几个脚本上工作。我做了一些,现在我尝试做一个集中所有脚本的启动器

我认为我在子流程方面做得很好,但我有一些困难

我尝试使用以下行启动脚本:

subprocess.Popen(['python', "E:/path/rocksmith/rocksmith.pyw"], shell=True)
但是python给了我一个没有这样的文件或目录错误的提示。 在我想要启动的脚本(rocksmith.pyw)中,我用open()打开了一些文本文件,我猜python找不到.txt文件,因为.txt不在启动程序目录中,对吗

我的目录是这样的:

Launcher folder
 - launcher.py
   * Script 1 folder
     - Script1.py
     - text.txt
   * Script 2 folder
     - Script2.py
     - text.txt
   * Script 3 folder
     - Script3.py
     - image.gif
我不知道我的解释是否正确。 我只是想启动一些脚本,在一个“超级脚本”


谢谢。

如果错误发生在
rocksmith.pyw
尝试打开文件时,您可能需要使用
cwd
kwarg to
Popen
。这将更改运行脚本的工作目录,以便
rocksmith.pyw
中的相对路径将按预期解析

subprocess.Popen(['python', "E:/path/rocksmith/rocksmith.pyw"], cwd='/path/to/rocksmith/stuff')

你从
打印(path.path+“/rocksmith/rocksmith.pyw”)
中看到了什么?哦,对不起,这只是到达rocksmith.pyw E的绝对路径:/path/rocksmith/rocksmith.pyw你的
路径是什么?它的值是如何分配的?是在运行rocksmith.pyw时出现的“没有这样的文件或目录”还是在rocksmith.pyw试图打开文件时出现的?为什么在UNIX上,
shell=True
?在这种情况下,
shell=True
是有害的--
python
单独被解析为shell脚本,另外一个参数将被忽略,因为第一个参数中给出的脚本从不查看其后续参数(不引用
$0
$1
,等等)。不过,这可能不会对Windows产生影响;命令行处理是。。。那里不一样。