Python 中的硒问题(也许安装 chrome webdriver)



我想我已经正确安装了chrome Web驱动程序,尽管这可能是问题所在,但是当我运行命令提示符并键入" chromedriver"时,它会运行,但是当我进入sublime并尝试转到google并打印标题和URL以验证一切正常时,我收到此错误

我不太确定它是什么意思或它想对我说什么

我正在运行的代码

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
print(driver.title)
print(driver.current_url)

我遇到的错误

Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 900, in _find_spec
AttributeError: '_SixMetaPathImporter' object has no attribute 'find_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersCodingDesktoppythonselenium testing.py", line 1, in <module>
from selenium import webdriver
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesseleniumwebdriver__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox  # noqa
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesseleniumwebdriverfirefoxwebdriver.py", line 29, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesseleniumwebdriverremotewebdriver.py", line 27, in <module>
from .remote_connection import RemoteConnection
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesseleniumwebdriverremoteremote_connection.py", line 24, in <module>
import urllib3
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3__init__.py", line 7, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 902, in _find_spec
File "<frozen importlib._bootstrap>", line 879, in _find_spec_legacy
File "<frozen importlib._bootstrap>", line 449, in spec_from_loader
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3packagessix.py", line 212, in is_package
return hasattr(self.__get_module(fullname), "__path__")
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3packagessix.py", line 116, in __getattr__
_module = self._resolve()
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3packagessix.py", line 113, in _resolve
return _import_module(self.mod)
File "C:UsersCodingAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesurllib3packagessix.py", line 82, in _import_module
__import__(name)
File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0libhttpclient.py", line 71, in <module>
import email.parser
File "C:UsersCodingDesktoppythonemail.py", line 8, in <module>
loop (
NameError: name 'loop' is not defined
[Finished in 0.2s]

您遇到的问题如下:

  • 您导入webdriver
  • 导入
  • 触发了email.parser的导入,正如我们在错误中看到
  • 的那样
File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0libhttpclient.py", line 71, in <module>
import email.parser
  • Python 解释器在其路径中查找名为email的模块。
  • 找到了一个模块,但它不是它正在寻找的模块,而是您自己的模块,正如我们在错误中看到的那样
File "C:UsersCodingDesktoppythonemail.py", line 8, in <module>
loop (
  • 正如我们所看到的,该模块是在C:UsersCodingDesktoppythonemail.py找到的,正如我所怀疑的那样,这不是解释器正在搜索的实际模块的路径。

相关内容

  • 没有找到相关文章

最新更新