Selenium无法在Python中工作,Ubuntu 16.04

问题描述:

我使用pip安装了硒。并把geckodriver放在/ usr/bin中。 我保持ubuntu更新。 Firefox已更新。Selenium无法在Python中工作,Ubuntu 16.04

当我运行下面的程序:

from selenium import webdriver 

browser = webdriver.Firefox() 
browser.get('http://google.com') 

上运行我:

结束。 回溯(最近通话最后一个): 文件 “seleniumIntro.py”,3号线,在 硒进口的webdriver 文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/ INIT .py“,第18行,来自.firefox.webdriver的 导入WebDriver作为Firefox#noqa 文件”/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py“,第32行,在 from .extension_connection import ExtensionConnection 文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py”,第24行,来自selenium.webdriver.remote的 .remote_connection import RemoteConnection 文件“/usr/local/lib/python2.7/ dist-packages/selenium/webdriver/remote/remote_connection.py“,第35行,在 之内。 import utils 文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/utils.py”,第22行,在 import zipfile 文件“/usr/lib/python2.7/ zipfile.py”,线501,在 类ZipExtFile(io.BufferedIOBase): AttributeError的: '模块' 对象没有属性 'BufferedIOBase'


(程序退出,代码:1) 按下返回继续

为什么会发生? 谢谢。

+0

你有机会在你的路上有一个名为'io'的模块吗? –

+0

我该如何检查? –

+0

试试'import io;从'Python'外壳IO .__ file__'检查哪些'io'模块实际上是在你的代码中使用 – Andersson

它使用python3,使用pip3安装,并运行相同的程序。 谢谢你帮助我。