我在.exe python脚本(Selenium)时遇到错误。虽然脚本运行良好



我正在尝试制作python脚本的.exe(selenium(。脚本本身运行良好,不会出现错误或警告。但当我制作.exe并尝试运行时,它会出现这些错误。

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

这是一些代码

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")

您需要像这样导入future

from __future__ import *

在失败的情况下,使用pip像这样安装它(使用sudo作为MAC(:

pip install future

以下是有关安装future的更多信息。

相关内容

  • 没有找到相关文章

最新更新