keischan 2024-08-01 10:27 采纳率: 0%
浏览 12

python使用selenium无法运行(罕见)

**请教各位,python 运行 selenium没反应,是什么问题?情况如下(Python版本3.1.2,selenium版本4.1.0):
**
python使用selenium代码


from selenium import webdriver
driver = webdriver.Edge()
driver.get(r'https://www.baidu.com/')

**我的系统环境变量设置如下:
**

img

img

**运行后没有反应,强制暂停时报下面的错误:
**

Traceback (most recent call last):
File "E:\Program Files (x86)\Python\Lib\socket.py", line 838, in create_connection
sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "G:\Justus\Python project\projecOne\pythonProject\Hello.py", line 7, in
driver = webdriver.Edge()
^^^^^^^^^^^^^^^^
File "G:\Justus\Python project\projecOne\pythonProject.venv\Lib\site-packages\selenium\webdriver\edge\webdriver.py", line 62, in init
super(WebDriver, self).init(DesiredCapabilities.EDGE['browserName'], "ms",
File "G:\Justus\Python project\projecOne\pythonProject.venv\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in init
self.service.start()
File "G:\Justus\Python project\projecOne\pythonProject.venv\Lib\site-packages\selenium\webdriver\common\service.py", line 99, in start
if self.is_connectable():
^^^^^^^^^^^^^^^^^^^^^
File "G:\Justus\Python project\projecOne\pythonProject.venv\Lib\site-packages\selenium\webdriver\common\service.py", line 116, in is_connectable
return utils.is_connectable(self.port)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\Justus\Python project\projecOne\pythonProject.venv\Lib\site-packages\selenium\webdriver\common\utils.py", line 107, in is_connectable
socket_ = socket.create_connection((host, port), 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Program Files (x86)\Python\Lib\socket.py", line 845, in create_connection
exceptions.clear() # raise only the last error
^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

  • 写回答

1条回答 默认 最新

  • 程序员小羊! 2024-08-03 09:49
    关注

    你好,这个情况是没有装Edge驱动,你重新把驱动导进去看下

    评论

报告相同问题?

问题事件

  • 创建了问题 8月1日

悬赏问题

  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见
  • ¥15 一共有五道问题关于整数幂的运算还有房间号码 还有网络密码的解答?(语言-python)
  • ¥20 sentry如何捕获上传Android ndk 崩溃
  • ¥15 在做logistic回归模型限制性立方条图时候,不能出完整图的困难
  • ¥15 G0系列单片机HAL库中景园gc9307液晶驱动芯片无法使用硬件SPI+DMA驱动,如何解决?