0

在 Windows 中使用 selenium webdriver.chrome 时出现以下错误。我正在使用 Windows 10 Home 64 位和 python 版本 Python 3.8.3 64 位。我已经尝试了所有可以搜索但无法解决的解决方案。

以下是错误信息:

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

这是代码

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

运行第二行代码后出现错误消息。

感谢您在这方面的帮助。

4

2 回答 2

0

有时由于防火墙而发生。能不能把防火墙关掉再检查一下。

于 2021-02-12T18:50:01.203 回答
0
  1. 将 python 3.7 下载到单独的位置。
  2. 下载 pycharm 社区版。
  3. 打开pycharm并用python 3.7设置一个新的虚拟环境
  4. 将 selenium 安装到该虚拟环境中。
  5. 运行代码。
于 2021-02-12T18:57:36.730 回答