1

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.PhantomJS()

the script fails with the following error

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-3-6658ea2466a9> in <module>()
----> 1 driver = webdriver.PhantomJS()

/Users/yuyang/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/yuyang/anaconda/lib/python2.7/site-packages/selenium/webdriver/common/service.pyc in start(self)
     79                 raise WebDriverException(
     80                     "'%s' executable needs to be in PATH. %s" % (
---> 81                         os.path.basename(self.path), self.start_error_message)
     82                 )
     83             elif err.errno == errno.EACCES:

WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 

OS: OSX

phantomjs has already been installed:

enter image description here

My error:

enter image description here

aL_eX
  • 1,453
  • 2
  • 15
  • 30
yang yu
  • 11
  • 3

0 Answers0