简体   繁体   English

在 python 中从 selenium 导入 webdriver 时出错

[英]error while importing webdriver from selenium in python

The first thing I wanted to do is, installing Selenium in Windows and import webdriver from selenium.我想做的第一件事是,在 Windows 中安装 Selenium 并从 selenium 导入 webdriver。

So, I installed Selenium with pip install selenium and tried to import webdriver with:因此,我使用pip install selenium安装了 Selenium 并尝试使用以下命令导入 webdriver:

from selenium import webdriver

But I got the error:但我得到了错误:

File "C:\\Users\\VIJAY\\Desktop\\selenium.py", line 2, in from selenium import webdriver ImportError: cannot import name 'webdriver'文件“C:\\Users\\VIJAY\\Desktop\\selenium.py”,第 2 行,在 from selenium import webdriver ImportError: cannot import name 'webdriver'

Where am I going wrong?我哪里错了?

Rename your file from selenium.py to something else.将您的文件从 selenium.py 重命名为其他名称。 Also, make sure there is nothing named selenium in your desktop folder.另外,请确保桌面文件夹中没有名为 selenium 的内容。 You are probably not importing the library, but rather a python file.您可能没有导入库,而是导入了一个 python 文件。

Change your program name to something else like scraping if you are practicing it.如果您正在练习,请将您的程序名称更改为其他名称,例如抓取。 Or else try installing it from the python console.或者尝试从 python 控制台安装它。

import selenium
from selenium import webdriver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM