在MacOS上使用python的Selenium总是提供OSError:[Errno 8]Exec表单

2024-09-28 05:39:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我的系统: -马科斯塞拉(10.12.6) -Python 3.5.2版 -硒3.8.1

我正在尝试将selenium与python结合使用,这样我就可以自动滚动浏览器页面(google图像搜索结果,以抓取图像)。在

我已经完成了brew install chromedriver,还从官方chromerepo https://sites.google.com/a/chromium.org/chromedriver/downloads(版本2.35)下载了二进制文件,并将其放在我添加到系统路径的路径(/Users/me/bin/chromedriver)中。在

每当我想跑的时候

from selenium import webdriver test = webdriver.Chrome() 甚至test = webdriver.Chrome('/Users/me/bin/chromedriver')

我刚得到一个错误:OSError: [Errno 8] Exec format error

我对此做了大量的研究,但所有的解决方案都只是重复我已经做过的。在

以下是整个错误消息:


In [15]: test = webdriver.Chrome()

OSError                                   Traceback (most recent call last)
<ipython-input-15-e726c5f1fb80> in <module>()
----> 1 test = webdriver.Chrome()

~/anaconda/envs/rllab3/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options)
     66             service_args=service_args,
     67             log_path=service_log_path)
---> 68         self.service.start()
     69
     70         try:

~/anaconda/envs/rllab3/lib/python3.5/site-packages/selenium/webdriver/common/service.py in start(self)
     74                                             stdout=self.log_file,
     75                                             stderr=self.log_file,
---> 76                                             stdin=PIPE)
     77         except TypeError:
     78             raise

~/anaconda/envs/rllab3/lib/python3.5/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
    945                                 c2pread, c2pwrite,
    946                                 errread, errwrite,
--> 947                                 restore_signals, start_new_session)
    948         except:
    949             # Cleanup if the child failed starting.

~/anaconda/envs/rllab3/lib/python3.5/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1549                             else:
   1550                                 err_msg += ': ' + repr(orig_executable)
-> 1551                     raise child_exception_type(errno_num, err_msg)
   1552                 raise child_exception_type(err_msg)
   1553

OSError: [Errno 8] Exec format error


Tags: intestselfloglibseleniumserviceargs

热门问题