ImportError: cannot import name 'webdriver'

前端 未结 6 1179
梦毁少年i
梦毁少年i 2020-12-15 15:31

I am a newbie for selenium python. I have installed python, pip etc.. I am trying to run the below code but it is showing error:

ImportError: cannot

相关标签:
6条回答
  • 2020-12-15 16:03
    1. if your file is selenium.py rename it.
    2. Pay attention to have import Keys instead of import keys
    0 讨论(0)
  • 2020-12-15 16:09

    Step 1: First rename filename if saved with selenium.py and delete selenium.pyc. mv selenium.py test.py rm selenium.pyc Step 2: import module selenium if not already installed. pip install selenium

    0 讨论(0)
  • 2020-12-15 16:18

    I solved it by reinstalling the older version of selenium package because the newest version doesn't support Python 2.6.6 which in my case was installed and I didn't have root access to install the new one.

    While the newest version of selenium package doesn't have support for Python 2.6.6, I had to downgrade by reinstalling the selenium package with lower version

    pip uninstall selenium
    pip install --user selenium==3.5.0
    
    0 讨论(0)
  • 2020-12-15 16:21

    Deepa, it is likely a 'path not found' issue. Add as many paths as relevant to help the IDE find selenium and webdriver. For example, on my Mac, I've added all the following paths so nothing is missed :

    file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5 file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium/common file:///Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium-3.0.0b2/py/selenium/webdriver

    0 讨论(0)
  • 2020-12-15 16:23

    First, you must install the selenium by using pip or pipenv:

    pip install selenium
    

    If your file name is selenium.py, change it to something else and delete .pyc files or the __pycache__ directory if exists.

    0 讨论(0)
  • 2020-12-15 16:28

    It says that webdriver cant be import.So I assume you have Selenium installed.

    So I can only assume that the selenium lied in different place in your path.

    Maybe you have accidently create a file named selenium ?

    0 讨论(0)
提交回复
热议问题