Traceback (most recent call last):File "1.py", line 348, in on_888File "os.py", line 986, in popenFile "subprocess.py", line 667, in __init__File "subprocess.py", line 908, in _get_handlesOSError: [WinError 6] 句柄无效。os.popen(r'"cmd /c start /wait \\IP\t\p.exe"','w') 时报上面的错os.popen(r'"cmd /c start /wait \\IP\t\p.exe"','w',1) 时报上面的错os.popen(r'"cmd /c start /wait \\IP\t\p.exe"','r',1) 时报下面的错os.popen(r'"cmd /c start /wait \\IP\t\p.exe"','r') 时报下面的错File "os.py", line 980, in popenFile "subprocess.py", line 667, in __init__File "subprocess.py", line 890, in _get_handlesOSError: [WinError 6] 句柄无效。请问该如何解决问题来自 OS.SYSTEM 安装软件时条用 shell有一个黑框,想去掉网友说 os.popen可以解决,但是pyinstaller 打包后出现问题pycharm测试正常请大神帮忙解决 谢谢
2 回答

SMILET
TA贡献1796条经验 获得超4个赞
你打包成exe后,命令行应该是pyinstller -Fw xxx.py
你加上了w参数也就是把console设置成了flase;那么os.popen()或者subprocess.popen()执行的时候没有载体,你只有把console设置成true,也就是命令改为pyinstaller -F xxx.py,这样你的os.popen()可执行,也能获得返回值。

精慕HU
TA贡献1845条经验 获得超8个赞
os.popen('ipconfig') 命令返回的结果在调试时乱码了:
output1 = os.popen('ipconfig')
o1=output1.read()
我猜这里输出的内容要和控制台设置的编码一致,我查了一下我的控制台编码时gbk
output1 = os.popen('ipconfig')
o1=output1.read().decode('gbk')
这样就好了!
添加回答
举报
0/150
提交
取消