I'm trying to get Selenium to use phantomjs on a Windows machine. My code compiles without any error:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import cookielib
import re
from splinter import Browser

driver = webdriver.PhantomJS('C:/Program Files (x86)/phantomjs-1.9.2-windows')

But every single time I run it I get the error

Traceback (most recent call last):
  File "E:/~PROJECT/disinfo/py/bs.py", line 8, in <module>
    driver = webdriver.PhantomJS('C:/Program Files (x86)/phantomjs-1.9.2-windows')
  File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 50, in __init__
  File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\service.py", line 63, in start
    raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
selenium.common.exceptions.WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen 

I've been getting this error for hours. "Unable to start phantomjs with ghostdriver". The simplest examples online show installing selenium with PIP and then phantomjs with NodeJS NPM, which is how I did it. Selenium's location is in my PYTHONPATH as well. I frankly have no idea what the hell this thing wants from me. Any ideas?

  • Same issues on basic code that once worked, thought I had broke my python structure at first.
    – Shane
    Nov 12, 2013 at 8:10
  • 1
    Welp, it looks like phantomjs' dev has admitted that the python bindings are behind. github.com/detro/ghostdriver/issues/236 So much for using phantomjs. Wish I would've known that before I spent several ****ing hours trying to wrangle phantomjs to life.
    – Alkanshel
    Nov 16, 2013 at 4:44
  • 1
    Same feelings here. Why it is so important to learn code and not libraries unless they are maintained by a large community. You can never expect one guy to maintain his project especially if not making any money off of the hard work.
    – Shane
    Nov 16, 2013 at 20:47

2 Answers 2


I ran into the same issue. I needed to provide the full path to the exe, as described in the documentation:

from selenium import webdriver
driver = webdriver.PhantomJS(executable_path='C:\phantomjs-1.9.2\phantomjs.exe')
  • This did indeed allow it to dial out, hooray. Now the only problem is, every element I try to print, it just gives me a "selenium.webdriver.phantomjs.webdriver.WebDriver object at 0x0000000002F54668" or a unicode ID. I recommend lorien's Grab instead. bitbucket.org/lorien/grab/src/…
    – Alkanshel
    Dec 7, 2013 at 23:20
  • true story!! wish I could upvote 5 times.
    – HelloW
    Dec 20, 2013 at 13:40
  • Didn't work for me... I had to edit service.py as per DT_Lvhyy's answer.
    – Deep-B
    Feb 17, 2014 at 20:47
  • It looks like for Ubuntu and Linux systems, ~ should be the actual path from root to the directory Mar 18, 2014 at 6:47

You need to modify ...\Python27\Lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\phantomjs\service.py

This google code page would help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.