【问题标题】:Python 3 Selenium NameError: name 'basestring' is not definedPython 3 Selenium NameError:未定义名称'basestring'
【发布时间】:2016-03-16 14:06:15
【问题描述】:

几周前,我在一台 Linux Mint(Ubuntu 衍生产品)机器上安装了 Selenium,并用它开发了一些 Puthon 报废脚本。一切正常。

现在,我试图在另一台机器上复制安装,同样在 Linux Mint 下,但我被卡住了。这是我得到的:

Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> l_driver = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 62, in __init__
    firefox_options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
NameError: name 'basestring' is not defined

我安装 Selenium 的方式和以前完全一样:

sudo pip3 install -U Selenium

安装似乎没问题,没有报任何错误。以前,我使用 apt 命令安装了 pip3:

sudo apt-get install python3-pip

也没有错误或问题。我用 pip3 安装了其他几个 Python 模块,它们都可以工作。

我的脚本都不会运行。他们都在我想打开 Firefox WebDriver 的第一行失败。然而,在我早期的机器上,一切仍然正常,我的所有脚本都像以前一样完美运行。

这到底是怎么回事?我错过了什么?这是 Python 2 与 3 的问题吗('basestring' 名称指向那个方向)?

【问题讨论】:

    标签: python linux python-3.x selenium


    【解决方案1】:

    在最新版本的 selenium (2.53.0) 中是 a bug

    【讨论】:

    猜你喜欢
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2020-09-04
    相关资源
    最近更新 更多