简体   繁体   English

python selenium webdriver chrome中的错误

[英]Error in python selenium webdriver chrome

I have the following errors when using the selenium webdriver.chrome in Windows.在 Windows 中使用 selenium webdriver.chrome 时出现以下错误。 I am using Windows 10 Home 64 bit and python verison Python 3.8.3 64-bit.我正在使用 Windows 10 Home 64 位和 python 版本 Python 3.8.3 64 位。 I have tried all solutions I could search but cannot solve it.我已经尝试了所有可以搜索但无法解决的解决方案。

The following is the error message:以下是错误信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\clive\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
    self.service = Service(
  File "C:\Users\clive\anaconda3\lib\site-packages\selenium\webdriver\chrome\service.py", line 41, in __init__
    service.Service.__init__(self, executable_path, port=port, env=env,
  File "C:\Users\clive\anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 42, in __init__
    self.port = utils.free_port()
  File "C:\Users\clive\anaconda3\lib\site-packages\selenium\webdriver\common\utils.py", line 37, in free_port
    free_socket.listen(5)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

This is the code这是代码

>>> from selenium import webdriver
>>> driver = webdriver.Chrome(executable_path = 'C:\\Users\\clive\\code\\chromedriver_win32\\chromedriver.exe')

Error message came out after the second line of the code is run.运行第二行代码后出现错误消息。

I appreciate your help on this.感谢您在这方面的帮助。

Sometimes it happens due to firewall.有时由于防火墙而发生。 Can you turn off the firewall and then check again.能不能把防火墙关掉再检查一下。

  1. Download python 3.7 to a separate location.将 python 3.7 下载到单独的位置。
  2. Download pycharm community edition.下载 pycharm 社区版。
  3. Open pycharm and set a new virtual environment with python 3.7打开 pycharm 并使用 python 3.7 设置新的虚拟环境
  4. Install selenium into that vertual environment.将 selenium 安装到该虚拟环境中。
  5. Run the code.运行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM