为什么我不能为硒导入Webdriver?

时间:2019-06-02 07:29:49

标签: python python-3.x import

我正在尝试从硒导入webdriveer,但它始终显示错误

这里有一些代码:

        from selenium import webdriver

如果我从cmd启动python解释器并编写代码,我就可以工作。

但是如果直接写入python空闲状态会失败。

这让我犯了一个长错误:

    Traceback (most recent call last): File "", line 1, in from selenium import     webdriver File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver__init__.py", 

    line 18, in from .firefox.webdriver import WebDriver as Firefox # noqa File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\firefox\webdriver.py", 


    line 29, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", 


    line 27, in <module>
from .remote_connection import RemoteConnection
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", 

    line 24, in <module>
import urllib3
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3__init__.py", 



    line 7, in <module>
from .connectionpool import (
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", 




    line 11, in <module>
from .exceptions import (
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\exceptions.py", 


    line 2, in <module>
from .packages.six.moves.http_client import (
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", 



    line 203, in load_module
mod = mod._resolve()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", 



    line 115, in _resolve
return _import_module(self.mod)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", 



    line 82, in _import_module import(name)    File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\http\client.py", 



    line 71, in <module>
    import email.parser
    ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

1 个答案:

答案 0 :(得分:-1)

可能看起来像您正在运行的Windows,是否需要转义?也许吗?

喜欢

C:\\\my\\\escaped\\\path