Python Windows 上的 Selenium Webdriver 错误

Python Selenium Webdriver Error on Windows

我需要 geckodriver 方面的帮助。我已将它安装在 Windows 的环境路径中,但我仍然遇到此错误,我真的不知道如何修复它。

  File "Raport_FR_CH_Nata.py", line 1, in <module>
    from selenium import webdriver
  File "C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\firefox\webdriver.py", line 26, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\webdriver.py", line 26, in <module>
    from .webelement import WebElement
  File "C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\webelement.py", line 43, in <module>
    getAttribute_js = pkgutil.get_data(_pkg, 'getAttribute.js').decode('utf8')
  File "C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\pkgutil.py", line 637, in get_data
    return loader.get_data(resource_name)
  File "<frozen importlib._bootstrap_external>", line 916, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\cursu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\getAttribute.js'

用户是运行Windows10.

谢谢, 我

根据 this 的回答,只有重新安装才是正确的方法。

引用

Incase the getAttribute.js file doesn't gets downloaded properly Selenium and webdriver modules may not work properly. The issue can arise if the Selenium Client encounters any error during its transmission or storage.

Selenium Team is currently working on the issue SeleniumHQ/selenium/5378 to generate the binary checksum of the Downloaded Selenium Client which will help you to avoid encountering errors which may have been introduced during its transmission or storage.

首先尝试卸载:

pip uninstall selenium

然后重新安装:

pip install selenium --upgrade