SeleniumHQ/selenium · error · AttributeError
module {__name__!r} has no attribute {name!r}
Error message
module {__name__!r} has no attribute {name!r} What it means
Raised as AttributeError by the module-level __getattr__ in selenium.webdriver.ie when an attribute name is not one of the lazily-loaded submodules ('options', 'service', 'webdriver'). This is Python's standard lazy import mechanism — the IE driver modules are only imported on first access to reduce import overhead, and accessing any other name raises a standard AttributeError just as if the attribute never existed.
Source
Thrown at py/selenium/webdriver/ie/__init__.py:28
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import importlib
_LAZY_SUBMODULES = ["options", "service", "webdriver"]
def __getattr__(name):
if name in _LAZY_SUBMODULES:
module = importlib.import_module(f".{name}", __name__)
globals()[name] = module
return module
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
def __dir__():
return sorted(_LAZY_SUBMODULES)
View on GitHub (pinned to aa36b38e69)
Solutions
- Import from the correct submodule: from selenium.webdriver.ie.webdriver import WebDriver
- Check the available names with dir(selenium.webdriver.ie) which returns ['options', 'service', 'webdriver']
- Use the correct attribute name from the _LAZY_SUBMODULES list
Example fix
// before from selenium.webdriver import ie driver = ie.driver # AttributeError // after from selenium.webdriver.ie.webdriver import WebDriver driver = WebDriver()
Defensive patterns
Strategy: validation
Validate before calling
import selenium.webdriver.ie as ie
if 'webdriver' in dir(ie):
from selenium.webdriver.ie.webdriver import WebDriver Type guard
def is_lazy_submodule(name: str) -> bool:
return name in ('options', 'service', 'webdriver') Try / catch
try:
from selenium.webdriver.ie import webdriver
except AttributeError:
from selenium.webdriver.ie.webdriver import WebDriver Prevention
- Import directly from submodules: from selenium.webdriver.ie.webdriver import WebDriver
- Check available names with dir(module) before attribute access
- Avoid guessing submodule names
When it happens
Trigger: Accessing selenium.webdriver.ie.SomeName where SomeName is not 'options', 'service', or 'webdriver'. This is standard Python attribute access behavior for a module using PEP 562 lazy loading.
Common situations: Typing a wrong module name (e.g., selenium.webdriver.ie.driver instead of selenium.webdriver.ie.webdriver). Trying to import a class directly from the package root instead of from its submodule. IDE auto-complete suggesting a non-existent name.
Related errors
- module {__name__!r} has no attribute {name!r}
- module {__name__!r} has no attribute {name!r}
- module {__name__!r} has no attribute {name!r}
- module 'selenium.webdriver' has no attribute {name!r}
- module {__name__!r} has no attribute {name!r}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/3ff3a5ccaa7c26f3.
Report an issue: GitHub.