简体   繁体   中英

Error in python selenium webdriver chrome

I have the following errors when using the selenium webdriver.chrome in Windows. I am using Windows 10 Home 64 bit and python verison Python 3.8.3 64-bit. 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.
  2. Download pycharm community edition.
  3. Open pycharm and set a new virtual environment with python 3.7
  4. Install selenium into that vertual environment.
  5. Run the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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