Home > Software engineering >  I'm getting errors in .exe of a python script (selenium). Although the script runs fine
I'm getting errors in .exe of a python script (selenium). Although the script runs fine

Time:09-30

I'm trying to make .exe of python script(selenium). The script itself runs fine without an error or warning. But when I make the .exe and try to run, it gives theses errors.

Traceback (most recent call last):
  File "main.py", line 4, in <module>
  File "C:\Users\Ahmad\output\main\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\Ahmad\output\main\selenium\webdriver\firefox\webdriver.py", line 26, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\Users\Ahmad\output\main\selenium\webdriver\remote\webdriver.py", line 46, in <module>
    from selenium.webdriver.support.relative_locator import RelativeBy
  File "C:\Users\Ahmad\output\main\selenium\webdriver\support\relative_locator.py", line 22, in <module>
    from selenium.webdriver.remote.webelement import WebElement
  File "C:\Users\Ahmad\output\main\selenium\webdriver\remote\webelement.py", line 17, in <module>
    from __future__ import annotations
ModuleNotFoundError: No module named '__future__'

Here is some code

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
wait = WebDriverWait(driver, 5)
driver.get("https://www.google.com/maps")

CodePudding user response:

You need to import future like this:

from __future__ import *

In the event that fails, use pip to install it like this (Use sudo for MAC):

pip install future

Here is more on installing future.

  • Related