问题描述
链接到我试图在我的代码中实现的原始代码。
<$ p从selenium导入webdriver
导入选项
$ b $ chop = webdriver.ChromeOptions()
chop.add_extension() 'Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options = chop)
我尝试合并代码,但是第二行,来自selenium.webdriver.chrome.options的
import选项
抛出一个错误
Traceback(最近一次调用最后一次):
在< module>中,第1行的文件< pyshell#6>
from selenium.webdriver.chrome.options import选项
ImportError:没有模块命名选项
我更新了硒,更新了镀铬汽油,这个问题并没有消失。我检查了stackoverflow,没有发现与我的问题有关的地方。
我解决了这个问题,在selenium2.7版本中没有options.py出于某种不寻常的原因。
我所做的只是使用mac osx的终端进行更新,但是您不能只更新它,您必须先删除所有预先存在的路径。因此,请使用
import sys
打印sys.path
找到您的硒路径,使用终端cd进入路径并删除每个附有硒元素的文件夹或文件。
在终端输入
sudo easy_install selenium
这个问题没有消失的问题是我在不删除文件夹的情况下调用sudo easy_install。出于某种原因,在删除所有内容并进行全新安装后,hickup消失了。
Link to the original code I'm trying to implement into my code.
Running Selenium WebDriver using Python with extensions (.crx files)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chop = webdriver.ChromeOptions()
chop.add_extension('Adblock-Plus_v1.4.1.crx')
driver = webdriver.Chrome(chrome_options = chop)
I tried incorporating the code, but the 2nd line,
from selenium.webdriver.chrome.options import Options
is tossing out an error
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
from selenium.webdriver.chrome.options import Options
ImportError: No module named options
I updated selenium, updated chromedriver, and this problem doesn't go away. I checked stackoverflow and nothing seems to be related to my problem where the module is found.
I fixed the problem, there was no options.py in the selenium2.7 version for some unusual reason.
All I did was update using terminal for mac osx, but you can't just update it, you have to delete all the pre existing paths first. So go find where your selenium is installed using
import sys
print sys.path
Find your selenium path, cd into the path using terminal and delete every folder or file with selenium attached to it.
In your terminal, type
sudo easy_install selenium
The problem I had where this problem didn't go away was I called sudo easy_install without deleting the folder. For some reason, the hickup was gone after I deleted everything and did a fresh install.
这篇关于硒webdriver导入选项给我一个ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!