我的系统:Ubuntu 14.04
Firefox版本:45.0
selenium包装:3.4.2
我在PATH中有geckodriver。安装了Selenium。 但是当我跑步时:
from selenium import webdriver
d = webdriver.Firefox()
我收到错误:
d = webdriver.Firefox()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-b37f2497d2bf> in <module>()
----> 1 d = webdriver.Firefox()
/home/jsingla/anaconda2/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, firefox_options, log_path)
140 capabilities.pop("marionette")
141 self.service = Service(executable_path, log_path=log_path)
--> 142 self.service.start()
143
144 capabilities.update(firefox_options.to_capabilities())
/home/jsingla/anaconda2/lib/python2.7/site-packages/selenium/webdriver/common/service.pyc in start(self)
72 self.process = subprocess.Popen(cmd, env=self.env,
73 close_fds=platform.system() != 'Windows',
---> 74 stdout=self.log_file, stderr=self.log_file)
75 except TypeError:
76 raise
/home/jsingla/anaconda2/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)
388 p2cread, p2cwrite,
389 c2pread, c2pwrite,
--> 390 errread, errwrite)
391 except Exception:
392 # Preserve original exception in case os.close raises.
/home/jsingla/anaconda2/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)
1022 raise
1023 child_exception = pickle.loads(data)
-> 1024 raise child_exception
1025
1026
OSError: [Errno 20] Not a directory
谁能告诉我什么是错的。
最初我遇到了丢失geckodriver的问题,但是一旦我将其添加到路径中,我就会遇到错误。
答案 0 :(得分:0)
这里回答类似的问题: https://stackoverflow.com/a/40399367/4206154
确保geckodriver路径是包含geckodriver的文件夹路径(不是实际的可执行文件路径)。