Python 镀铬问题

Python 镀铬问题,python,python-3.x,selenium,selenium-webdriver,Python,Python 3.x,Selenium,Selenium Webdriver,错误 回溯(最近一次呼叫最后一次): 文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py”,第72行,开头 self.process=subprocess.Popen(cmd,env=self.env, 文件“/Library/Frameworks/Python.framework/Versions/3.9/lib

错误

回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py”,第72行,开头
self.process=subprocess.Popen(cmd,env=self.env,
文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,第951行,在__
self.\u execute\u child(参数、可执行文件、预执行文件、关闭文件、,
文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py”,第1823行,在执行子进程中
引发子项异常类型(错误号、错误消息、错误文件名)
FileNotFoundError:[Errno 2]没有这样的文件或目录:“chromedriver”
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/Jasiu/PycharmProjects/pythonProject/Python project/webscaper.py”,第3行,在
browser=webdriver.Chrome()
文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site packages/selenium/webdriver/chrome/webdriver.py”,第73行,在__
self.service.start()
文件“/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py”,第81行,开头
引发WebDriverException(
selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要位于路径中。请参阅https://sites.google.com/a/chromium.org/chromedriver/home

也许问题在于没有chromedriver可执行文件,您可以在这里找到:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Jasiu/PycharmProjects/pythonProject/Python project/webscaper.py", line 3, in <module>
    browser = webdriver.Chrome()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
url='1〕https://www.youtube.com/watch?v=CHUxmVVH2AQ'

browser=webdriver.Chrome(“C:\development\chromedriver.exe”)#这是否回答了您的问题?
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/Jasiu/PycharmProjects/pythonProject/Python project/webscaper.py", line 3, in <module>
    browser = webdriver.Chrome()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
url = 'https://www.youtube.com/watch?v=CHUxmVVH2AQ'
browser = webdriver.Chrome("C:\development\chromedriver.exe") # <- Path to chromedriver
browser.get(url)
browser.find_element_by_xpath('//*[@id="thumbnail"]').click()