Python Selenium Mac os.devnull - OSError:[Errno 20]不是目录

时间:2016-12-15 02:17:27

标签: python selenium

编辑:能够通过卸载anaconda并重新安装来解决问题。通过conda install -c metaperl selenium安装了硒。不确定究竟是做了什么来修复它,但想发布我的解决方案只是因为其他人遇到了这个问题。

尝试使用利用selenium pahantomjs webdriver的库。任何关于关闭日志记录的搜索都说使用service_log_path=os.devnull可以在任何操作系统上使用。尝试设置service_log_path='/dev/null',并使用默认的None,但无济于事。我为/dev/null/不是目录而收到错误的原因是什么?

这是我的错误:

/Users/name/anaconda/lib/python2.7/site-packages/sportsref-0.7.3-py2.7.egg/sportsref/utils.pyc in get_html(url)
     23     start = time.time()
     24     d = webdriver.PhantomJS(service_args=['--load-images=false']
---> 25                             ,service_log_path=r'/dev/null'
     26                             )
     27     d.set_window_size(10000, 10000)

/Users/name/anaconda/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.pyc in __init__(self, executable_path, port, desired_capabilities, service_args, service_log_path)
     50             service_args=service_args,
     51             log_path=service_log_path)
---> 52         self.service.start()
     53 
     54         try:

/Users/name/anaconda/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

/Users/name/anaconda/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)
    709                                 p2cread, p2cwrite,
    710                                 c2pread, c2pwrite,
--> 711                                 errread, errwrite)
    712         except Exception:
    713             # Preserve original exception in case os.close raises.

/Users/name/anaconda/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)
   1341                         raise
   1342                 child_exception = pickle.loads(data)
-> 1343                 raise child_exception
   1344 
   1345 

OSError: [Errno 20] Not a directory

0 个答案:

没有答案