Python中的selenium问题(可能安装chrome webdriver)

Python中的selenium问题(可能安装chrome webdriver),python,python-3.x,selenium-webdriver,selenium-chromedriver,Python,Python 3.x,Selenium Webdriver,Selenium Chromedriver,我想我已经正确安装了ChromeWeb驱动程序,虽然这可能是问题所在,但当我运行命令提示符并键入“chromedriver”时,它会运行,但当我进入sublime并尝试转到google打印标题和URL以验证是否正常工作时,我会出现此错误 我真的不知道它是什么意思,也不知道它想对我说什么 我正在运行的代码 from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.google.com") p

我想我已经正确安装了ChromeWeb驱动程序,虽然这可能是问题所在,但当我运行命令提示符并键入“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:\Users\Coding\Desktop\python\selenium testing.py", line 1, in <module>
    from selenium import webdriver
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module>
    from .remote_connection import RemoteConnection
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\remote_connection.py", line 24, in <module>
    import urllib3
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\exceptions.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:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 212, in is_package
    return hasattr(self.__get_module(fullname), "__path__")
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 116, in __getattr__
    _module = self._resolve()
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 71, in <module>
    import email.parser
  File "C:\Users\Coding\Desktop\python\email.py", line 8, in <module>
    loop (
NameError: name 'loop' is not defined
[Finished in 0.2s]
我遇到的错误

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:\Users\Coding\Desktop\python\selenium testing.py", line 1, in <module>
    from selenium import webdriver
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module>
    from .remote_connection import RemoteConnection
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\remote_connection.py", line 24, in <module>
    import urllib3
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\exceptions.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:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 212, in is_package
    return hasattr(self.__get_module(fullname), "__path__")
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 116, in __getattr__
    _module = self._resolve()
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 113, in _resolve
    return _import_module(self.mod)
  File "C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 71, in <module>
    import email.parser
  File "C:\Users\Coding\Desktop\python\email.py", line 8, in <module>
    loop (
NameError: name 'loop' is not defined
[Finished in 0.2s]
回溯(最近一次呼叫最后一次):
文件“”,第900行,在“查找”规范中
AttributeError:“\u SixMetaPathImporter”对象没有“find\u spec”属性
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:\Users\Coding\Desktop\python\selenium testing.py”,第1行,在
从selenium导入webdriver
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\selenium\webdriver\\ uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu.py”,第18行
从.firefox.webdriver将webdriver导入为firefox#noqa
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\selenium\webdriver\firefox\webdriver.py”,第29行
从selenium.webdriver.remote.webdriver将webdriver作为RemoteWebDriver导入
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\selenium\webdriver\remote\webdriver.py”,第27行
from.remote\u连接导入RemoteConnection
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\selenium\webdriver\remote\remote\u connection.py”,第24行
导入urllib3
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urlib3\\ uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
from.connectionpool导入HTTPConnectionPool、HTTPSConnectionPool、connection\u from\u url
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7\u qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urllib3\connectionpool.py”,第11行
从。例外导入(
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7\u qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urllib3\exceptions.py”,第2行
from.packages.six.moves.http_客户端导入不完全读取为httplib_不完全读取
文件“”,第983行,在_find_和_load中
文件“”,第963行,在“查找”和“加载”中解锁
文件“”,第902行,在“查找”规范中
文件“”,第879行,在_find_spec_legacy中
文件“”,第449行,在\u加载程序的规范\u中
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urllib3\Packages\six.py”,第212行,在is_package中
return hasattr(self.\uuuu get\u模块(全名),“\uuuuu路径”)
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urllib3\Packages\six.py”,第116行,在uu getattr中__
_模块=自我解析()
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7\u qbz5n2kfra8p0\LocalCache\Local Packages\Python37\site Packages\urllib3\Packages\six.py”,第113行,位于
返回导入模块(self.mod)
文件“C:\Users\Coding\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7\u qbz5n2kfra8p0\LocalCache\localpackages\Python37\site Packages\urllib3\Packages\six.py”,第82行,在导入模块中
__导入(名称)
文件“C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7.1776.0_x64_uuQBZ5N2KFRA8P0\lib\http\client.py”,第71行,在
导入email.parser
文件“C:\Users\Coding\Desktop\python\email.py”,第8行,在
环路(
NameError:未定义名称“循环”
[在0.2秒内完成]

您遇到的问题如下:

  • 您可以导入
    webdriver
  • 导入触发导入
    email.parser
    ,正如我们在错误中看到的那样
  • 正如我们所看到的,模块是在
    C:\Users\Coding\Desktop\python\email.py中找到的,正如我所怀疑的,这不是解释器正在搜索的实际模块的路径

看起来您有一个文件
email.py
。尝试重命名它,看看它是否有效,知道为什么吗?是的,对不起,我昨天时间不多;我会很快写一个答案