简体   繁体   中英

Python 3 Selenium NameError: name 'basestring' is not defined

A few weeks ago, I installed Selenium on a Linux Mint (an Ubuntu derivative) machine and developped a few Puthon scrapping scripts with it. Everyhting worked fine.

Now, I am trying to replicate the installation on another machine, also under Linux Mint, and I am stuck. This is what I get:

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

I installed Selenium exactly the same way as before:

sudo pip3 install -U Selenium

The installation seems ok and does not report any error. Previously, I had installed pip3 with the apt command:

sudo apt-get install python3-pip

Also no errors or problems. I installed a couple of other Python modules with pip3 and they all work.

None of my scripts will run. They all fail on the first line where I want to open a Firefox WebDriver. On my earlier machine however, everything still works fine and all my scripts run flawlessly as before.

What the heck is going on ? What am I missing ? Is this a Python 2 vs. 3 issue (the 'basestring' name points that way) ?

这是最新版selenium(2.53.0)中的一个错误

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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