Question:
I have just installed the latest version of geckodriver (v0.28.0).
But when creating a browser object (b = splinter.Browser()) I am faced with an OSError: [Errno 20] Not a directory.
When I open an IPython terminal, for Python 2.7:
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Then do:
from splinter import Browser
Everything is fine so far. Because the splinter Python library has installed properly.
Now when I try and instantiate a Browser() object:
b = Browser()
I get a large error that does not make much sense to me yet, my best guess is that there is some incompatibility between the new version of Mozilla Firefox's geckodriver and the splinter Python (2.7) library:
In [4]: b = Browser()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-4-935d10992ede> in <module>()
----> 1 b = Browser()
/home/osboxes/.local/lib/python2.7/site-packages/splinter/browser.pyc in Browser(driver_name, *args, **kwargs)
62 except KeyError:
63 raise DriverNotFoundError("No driver for %s" % driver_name)
---> 64 return driver(*args, **kwargs)
/home/osboxes/.local/lib/python2.7/site-packages/splinter/driver/webdriver/firefox.pyc in __init__(self, profile, extensions, user_agent, profile_preferences, fullscreen, wait_time, timeout, capabilities, headless, incognito, **kwargs)
76 firefox_options=firefox_options,
77 timeout=timeout,
---> 78 **kwargs
79 )
80
/home/osboxes/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, service_log_path, firefox_options, service_args, desired_capabilities, log_path, keep_alive)
162 service_args=service_args,
163 log_path=service_log_path)
--> 164 self.service.start()
165
166 capabilities.update(options.to_capabilities())
/home/osboxes/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.pyc in start(self)
74 stdout=self.log_file,
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
78 raise
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
392 p2cread, p2cwrite,
393 c2pread, c2pwrite,
--> 394 errread, errwrite)
395 except Exception:
396 # Preserve original exception in case os.close raises.
/usr/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
1045 raise
1046 child_exception = pickle.loads(data)
-> 1047 raise child_exception
1048
1049
OSError: [Errno 20] Not a directory
In [5]: b = Browser()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-5-935d10992ede> in <module>()
----> 1 b = Browser()
/home/osboxes/.local/lib/python2.7/site-packages/splinter/browser.pyc in Browser(driver_name, *args, **kwargs)
62 except KeyError:
63 raise DriverNotFoundError("No driver for %s" % driver_name)
---> 64 return driver(*args, **kwargs)
/home/osboxes/.local/lib/python2.7/site-packages/splinter/driver/webdriver/firefox.pyc in __init__(self, profile, extensions, user_agent, profile_preferences, fullscreen, wait_time, timeout, capabilities, headless, incognito, **kwargs)
76 firefox_options=firefox_options,
77 timeout=timeout,
---> 78 **kwargs
79 )
80
/home/osboxes/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, service_log_path, firefox_options, service_args, desired_capabilities, log_path, keep_alive)
162 service_args=service_args,
163 log_path=service_log_path)
--> 164 self.service.start()
165
166 capabilities.update(options.to_capabilities())
/home/osboxes/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.pyc in start(self)
74 stdout=self.log_file,
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
78 raise
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
392 p2cread, p2cwrite,
393 c2pread, c2pwrite,
--> 394 errread, errwrite)
395 except Exception:
396 # Preserve original exception in case os.close raises.
/usr/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
1045 raise
1046 child_exception = pickle.loads(data)
-> 1047 raise child_exception
1048
1049
OSError: [Errno 20] Not a directory
Background:
I am using Python version 2.7, and imported splinter
I have downloaded and installed geckodriver (the version: geckodriver-v0.23.0-linux64.tar.gz).
Using the four step method on this answer in Ask Ubuntu:
-
Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. For example:
wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
NOTE: the newest version is currently v0.28.0
-
Extract the file with:
tar -xvzf geckodriver* -
Make it executable:
chmod +x geckodriver -
Add the driver to your PATH so other tools can find it:
export PATH=$PATH:/path-to-extracted-file/geckodriver
There are many ways to do this that will work. The above works for me on Ubuntu 16.10 64-bit.
Related:
Coming in the next edit.
Aucun commentaire:
Enregistrer un commentaire