Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我已经导入了Selenium,我认为它是与Python一起安装的,我找不到哪里出了问题_Python_Python 3.x_Selenium - Fatal编程技术网

我已经导入了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计算机上:

  • 使用cmd.exe程序启动一个命令提示符,然后运行下面给出的pip命令来安装selenium
  • C:\Python35\Scripts\pip.exe安装selenium

    现在可以使用Python运行测试脚本了

    例如,如果您创建了一个基于Selenium的脚本并将其保存在C:\my\u Selenium\u script.py中,则可以如下方式运行它:

    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