python ModuleNotFoundError:没有名为“Common_Methods”的模块

2024-10-02 14:28:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图按照this示例生成对扩展的单击。 下面是我的代码

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import pyautogui
import json
import os
from Common_Methods.GenericMethods import *

options = webdriver.ChromeOptions()
options.add_argument("--load-extension=./Edit-This-Cookie")
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

driver.get("https://google.com")
# get the extension box
extn = pyautogui.locateOnScreen(os.path.join(GenericMethods.get_full_path_to_folder() + "/icon_16x16.png"))
# click on extension 
pyautogui.click(x=extn[0],y=extn[1],clicks=1,interval=0.0,button="left")

我发现了错误

    from Common_Methods.GenericMethods import *
    ModuleNotFoundError: No module named 'Common_Methods'

我试图检查在pip中是否有同名的模块,但没有。 我目前正在使用python版本3.9.0,我尝试切换到2.7,但包似乎仍然丢失

编辑: 删除from Common_Methods.GenericMethods import * 给出以下错误:-

NameError: name 'GenericMethods' is not defined

Tags: fromimportgetosdriverextensioncommonchrome