我已经导入了Selenium,我认为它是与Python一起安装的,我找不到哪里出了问题
当我运行代码时,它会说:我已经导入了Selenium,我认为它是与Python一起安装的,我找不到哪里出了问题,python,python-3.x,selenium,Python,Python 3.x,Selenium,当我运行代码时,它会说: from selenium import webdriver #This is where the error from getpass import getpass usr = input("enter your username or email id: ") pwd = getpass("Enter your password: ") driver = webdriver.Chrome() driver.get('https://www.facebook.c
from selenium import webdriver #This is where the error
from getpass import getpass
usr = input("enter your username or email id: ")
pwd = getpass("Enter your password: ")
driver = webdriver.Chrome()
driver.get('https://www.facebook.com/')
username_box = driver.find_element_by_id('email')
username_box.send_keys(usr)
password_box = driver.find_element_by_id('pass')
password_box.send_keys(pwd)
login_btn = driver.find_element_by_id('u_0_2')
login_btn.submit()
回溯(最近一次呼叫最后一次):
文件“C:\Users\jarre\OneDrive\Documents\FB automation.py”,第1行,在
从selenium导入webdriver
ModuleNotFoundError:没有名为“selenium”的模块
我不知道为什么Selenium是与Python一起安装的?Selenium本机没有包含在Python安装中
pip安装selenium
应该可以解决您的问题。看起来selenium没有安装
更好的方法是使用pip安装selenium软件包
Python 3.6在标准库中提供了pip。使用pip,您可以如下方式安装selenium:
pip install selenium
如果您在windows计算机上:
pip install selenium
有关更多信息,请参阅此您是如何安装Selenium的?pip install Selenium是一种很好的安装方法。我认为它是与python一起安装的,正如我搜索时所说的那样。请链接到告诉您安装python时也会自动获得Selenium的源代码。”Python 3.6在标准库中提供了pip。”。因为您运行的是命令行脚本,所以技术上不相关。@MadPhysicast:好吧,这是官方文档说的:()@MadPhysicast:我相信pip在标准库中是可用的,我们使用它通过命令行安装selenium。确实如此。任何不是您自己的话都应该用前导的
引用。
C:\Python35\python.exe C:\my_selenium_script.py