Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.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()打开程序时出错_Python_Linux_Ubuntu - Fatal编程技术网

Python 使用subprocess.Popen()打开程序时出错

Python 使用subprocess.Popen()打开程序时出错,python,linux,ubuntu,Python,Linux,Ubuntu,我正在运行Ubuntu。 如果我在终端中键入: >>> import subprocess >>> subprocess.Popen('firefox') 这是返回的: <subprocess.Popen object at 0xb76c080c> >>> nvfx_screen_get_param:95 - Warning: unknown PIPE_CAP 30 nvfx_screen_get_param:95 - Wa

我正在运行Ubuntu。 如果我在终端中键入:

>>> import subprocess
>>> subprocess.Popen('firefox')
这是返回的:

<subprocess.Popen object at 0xb76c080c>
>>> nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 30
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 30
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 55
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 56
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 59
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 58
nvfx_screen_get_param:95 -  Warning: unknown PIPE_CAP 30

这不是打开浏览器的最佳方式。或许可以试试这个:

import webbrowser
webbrowser.open("http://www.stackoverflow.com/")

顺便说一下,它已经返回到您的python终端,我可以在输出中看到这一点。进程中的stdout或stderr上出现了一些聊天,这可能会覆盖
>>提示
,但如果按几次Enter键,您可能会发现您仍然处于状态。

不是打开浏览器的最佳方式。或许可以试试这个:

import webbrowser
webbrowser.open("http://www.stackoverflow.com/")

顺便说一下,它已经返回到您的python终端,我可以在输出中看到这一点。进程中出现了一些关于stdout或stderr的聊天,这可能覆盖了
>>提示符
,但是如果您按几次Enter键,您可能会发现您仍然处于状态。

您可能对python模块感兴趣……我必须说,这非常酷!然而,这是无关的。我只是想让它打开一个变量程序,firefox突然从我的脑海中闪过。你可能对python的模块感兴趣……我必须说,这很酷!然而,这是无关的。我只是想让它打开一个变量程序,firefox突然从我脑海中消失了。@phileaton--这个“错误”看起来像是firefox的独特之处。这可能是一个问题,gui程序不知道如何与窗口管理器或其他东西通信……这不是一个错误,它只是警告子进程中的聊天者,如果您从gui启动firefox,您通常不会看到这些聊天者。有趣。我修改了代码,错误消失了。我就是这样修改它的:subprocess.Popen('firefox',stdout=PIPE,stderr=PIPE)您将阻塞这些管道,并最终以这种方式使其挂起(这些管道的缓冲区有限)。如果你不想看到那些喋喋不休的话,最好将它们重定向到
os.devnull
。@phileaton--“错误”看起来像是firefox独有的。这可能是一个问题,gui程序不知道如何与窗口管理器或其他东西通信……这不是一个错误,它只是警告子进程中的聊天者,如果您从gui启动firefox,您通常不会看到这些聊天者。有趣。我修改了代码,错误消失了。我就是这样修改它的:subprocess.Popen('firefox',stdout=PIPE,stderr=PIPE)您将阻塞这些管道,并最终以这种方式使其挂起(这些管道的缓冲区有限)。如果您不想看到那些喋喋不休的话,最好将它们重定向到os.devnull。