Python 3 Selenium 名称错误 : name 'basestring' is not defined

标签 python linux python-3.x selenium

几周前,我在 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”名称表明了这一点)?

最佳答案

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

关于Python 3 Selenium 名称错误 : name 'basestring' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36038033/

相关文章:

python - Python 3.5 中的 FFMPEG 命令实际上并不创建音频文件

python - 重新调整 PIL 图像的强度

python - pyqt4窗口调整大小事件

sql - Python3 将 jsonb 数组插入 Postgresql 9.5

python - 将 Pandas DataFrame 行合并为一列中的字符串

python - Django 1.8 和 Gmail - SMTPAuthenticationError 用户名和密码不被接受

linux - 如何使用 Docker 远程 API?

c++ - 如何将XImage保存为位图?

linux - 如何在 brackground "watch"命令中记录到文件?

django - 可调用的Django迁移默认值生成相同的条目