I am running Ubuntu. If I type this into the terminal:
我正在运行Ubuntu。如果我在终端输入:
>>> import subprocess
>>> subprocess.Popen('firefox')
This is returned:
这是返回:
<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
It doesn't return back to the python terminal: >>>
它不会返回到python终端:>>>
I am new to python on linux -- can anyone show me what am I doing wrong? Thanks.
我是linux上的新手 - 有人能告诉我我做错了什么吗?谢谢。
EDIT:
For anyone interested in fixing this, I solved the immediate issue this way:
对于有兴趣解决这个问题的人,我通过这种方式解决了当前问题:
from subprocess import PIPE,Popen
Popen('firefox',stdout=PIPE,stderr=PIPE)
1 个解决方案
#1
1
Not the best way to open a browser. Maybe try this instead:
不是打开浏览器的最佳方式。也许试试这个:
import webbrowser
webbrowser.open("http://www.*.com/")
By the way, it has returned back to your python terminal, I can see that in the output. There has been some chatter on stdout or stderr from the process, which may have overwritten the >>> prompt
, but if you press Enter a few times you will probably find you're still at the REPL.
顺便说一下,它已经返回到你的python终端,我可以在输出中看到它。这个过程中有一些关于stdout或stderr的喋喋不休,可能已经覆盖了>>>提示符,但是如果你按Enter键几次,你可能会发现你仍然在REPL。
#1
1
Not the best way to open a browser. Maybe try this instead:
不是打开浏览器的最佳方式。也许试试这个:
import webbrowser
webbrowser.open("http://www.*.com/")
By the way, it has returned back to your python terminal, I can see that in the output. There has been some chatter on stdout or stderr from the process, which may have overwritten the >>> prompt
, but if you press Enter a few times you will probably find you're still at the REPL.
顺便说一下,它已经返回到你的python终端,我可以在输出中看到它。这个过程中有一些关于stdout或stderr的喋喋不休,可能已经覆盖了>>>提示符,但是如果你按Enter键几次,你可能会发现你仍然在REPL。