[英]Issues with selenium in Python (Maybe installing chrome webdriver)
I think I've installed chrome web driver correctly although it may be the issue, but when i run command prompt and type "chromedriver" it runs, but when i go into sublime and just try to go to google and print the title and URL to verify that things are working i get this error我想我已经正确安装了 chrome web 驱动程序,尽管这可能是问题所在,但是当我运行命令提示符并输入“chromedriver”时它会运行,但是当我进入 sublime 并尝试去谷歌并打印标题和 URL 时为了验证事情是否正常,我收到此错误
I am not really sure what it means or what it is trying to say to me我不太确定这意味着什么,或者它想对我说什么
The code I'm running我正在运行的代码
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
print(driver.title)
print(driver.current_url)
The Error I'm getting我得到的错误
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]
The Problem you are having is the following:您遇到的问题如下:
webdriver
您导入网络驱动webdriver
email.parser
as we see in the error正如我们在错误中看到的那样,导入会触发email.parser
的导入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
email
. python 解释器在其路径中查找名为email
的模块。File "C:\Users\Coding\Desktop\python\email.py", line 8, in <module>
loop (
C:\\Users\\Coding\\Desktop\\python\\email.py
and, as I suspected, this is not the path of the actual module the interpreter was searching for.正如我们所见,该模块位于C:\\Users\\Coding\\Desktop\\python\\email.py
并且,正如我所怀疑的,这不是解释器正在搜索的实际模块的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.