webbrowser.get — 找不到可运行的浏览器 [英] webbrowser.get — could not locate runnable browser

查看:73
本文介绍了webbrowser.get — 找不到可运行的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Google Chrome 访问互联网,但每次使用 webbrowser.open(url) 时它都会打开 IE.

I am trying to access the internet with Google Chrome but every time I use webbrowser.open(url) it opens IE.

所以我检查以确保我将 Chrome 作为我的默认设置,我确实这样做了,并且我尝试使用 get() 函数来链接实际的 Chrome 应用程序,但它却给了我这个错误:

So I checked to make sure I have Chrome as my default, which I do, and I tried using the get() function to link the actual Chrome application but it gives me this error instead:

File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\webbrowser.py", line 51, in get raise Error("could not locate runnable browser") webbrowser.Error: could找不到可运行的浏览器

File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\webbrowser.py", line 51, in get raise Error("could not locate runnable browser") webbrowser.Error: could not locate runnable browser

我也尝试打开其他浏览器,但它给出了同样的错误.它还将 IE 读取为我的默认浏览器,并且只能运行.

I also tried to open other browsers but it gives the same error. It also reads IE as my default and only runnable browser.

会发生什么?有没有替代品?

What could be happening? Is there an alternative?

使用 Python 3.6.

Using Python 3.6.

推荐答案

我也遇到了同样的问题.您可以做的是注册浏览器,然后启动一个新选项卡.像这样:

I too faced the same problem. What you can do is to register the browser and then launch a new tab. Something like this:

import webbrowser    
urL='https://www.google.com'
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
webbrowser.register('chrome', None,webbrowser.BackgroundBrowser(chrome_path),1)
webbrowser.get('chrome').open_new_tab(urL)

它有效.从 docs webbrowser.register(name, constructor, instance=无).

And it works. From the docs webbrowser.register(name, constructor, instance=None).

这篇关于webbrowser.get — 找不到可运行的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆