I am attempting to run this script:
https://github.com/Chillee/coursera-dl-all
However, the script fails at the line session = webdriver.PhantomJS()
with the following error
Traceback (most recent call last): File "dl_all.py", line 236, in <module> session = webdriver.PhantomJS() File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__ self.service.start() File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 69, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f6f632864d0>> ignored
How do I add phantomjs to my PATH? I am running ubuntu 16.04 and installed selenium via npm install selenium
.
Selenium considers PhantomJS as deprecated, so you need to us either Chrome or Firefox in headless mode.
PhantomJS is a headless Webkit, which has a number of uses. In this example, we'll be using it, in conjunction with Selenium WebDriver, for conducting basic system tests directly from the command line. Since PhantomJS eliminates the need for a graphical browser, tests run much faster.
you need to download the DRIVER
after that session = webdriver.PhantomJS("c:\driverPath")
Working Solution:
Assumming you are on windows - it is similar for linux
1) download phantomjs here: http://phantomjs.org/download.html pick windows/linux accordingly
2) unzip your phantomjs-2.1.1-windows.zip and save it to for example c drive such as C:\phantomjs-2.1.1-windows\bin (in here there is a phantomjs.exe that is the execute that your system needs)
3) On Windows10 edit your environment path to include this bin folder C:\phantomjs-2.1.1-windows\bin such as this example
4) you may or may not restart your machine. Done! it should work! (Webdriver looks for phantomjs.exe and it should be ready now)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With