Can't run run script due to ModuleNotFoundError: No module named 'webdriver_manager' Ubuntu Python

Viewed 1835

I'm using anaconda, jupyter and have pip and pip3 installed webdriver_manager yet I keep getting this error when I try to run my python3 code. When I run the code in terminal

$ pip install webdriver_manager
Collecting webdriver_manager
  Using cached https://files.pythonhosted.org/packages/dd/3c/2e2d71aeb28ee73ecaf12b545542b082ca81c8c091bb05028c52c42696ce/webdriver_manager-2.4.0-py2.py3-none-any.whl
Collecting requests (from webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl
Collecting configparser (from webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Collecting crayons (from webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/5b/0d/e3fad4ca1de8e70e06444e7d777a5984261e1db98758b5be3e8296c03fe9/crayons-0.4.0-py2.py3-none-any.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl
Collecting chardet<4,>=3.0.2 (from requests->webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl
Collecting idna<3,>=2.5 (from requests->webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl
Collecting colorama (from crayons->webdriver_manager)
  Using cached https://files.pythonhosted.org/packages/c9/dc/45cdef1b4d119eb96316b3117e6d5708a08029992b2fee2c143c7a0a5cc5/colorama-0.4.3-py2.py3-none-any.whl
Installing collected packages: urllib3, chardet, certifi, idna, requests, configparser, colorama, crayons, webdriver-manager
Successfully installed certifi-2020.6.20 chardet-3.0.4 colorama-0.4.3 configparser-4.0.2 crayons-0.4.0 idna-2.10 requests-2.24.0 urllib3-1.25.10 webdriver-manager-2.4.0

In my IDE I get this output

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import requests
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from webdriver_manager.firefox import GeckoDriverManager

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-87a373070a15> in <module>
      9 import requests
     10 from selenium.webdriver.firefox.options import Options as FirefoxOptions
---> 11 from webdriver_manager.firefox import GeckoDriverManager

ModuleNotFoundError: No module named 'webdriver_manager'

I have been trying several solutions posted on SO but none have fixed the problem

2 Answers

I had the same issue. In my case the solution was python3.8 -m pip install webdriver_manager and now it works

There is another solution in case you are using Visual Studio Code;

VSCode sometimes is unable to autocomplete some python packages which cause imports to fail even when they run correctly when ran from CLI. This happens very often. The solution is to add such paths to the autocomplete path list on VSCode settings.json.

settings.json is found at:

  • Windows: %APPDATA%\Code\User\settings.json
  • macOS: $HOME/Library/Application Support/Code/User/settings.json
  • Linux: $HOME/.config/Code/User/settings.json

And add the path to the webdriver_manager package to the python.autoComplete.extraPaths, in this case the path to like this:

{
   "editor.suggestSelection": "first",
   "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
   "git.autofetch": true,
   "python.languageServer": "Microsoft",
   "python.autoComplete.extraPaths": [
       "path/to/webdriver_manager"
    ]
}
Related