Forums

pyvirtualdisplay in Python 3.4

I am trying to use selenium in a Python 3.4 console. In your forums you suggest the use of pyvirtualdisplay but when I run the test code you suggested

from pyvirtualdisplay import Display
from selenium import webdriver
import traceback
browser = None

try:
    display = Display().start()
    browser = webdriver.Firefox()
    browser.get('http://www.google.com')
    print browser.title

except Exception as e:
    traceback.print_exc()

finally:
    if browser is not None:
        browser.quit()
    display.stop()

I get the following message

Traceback (most recent call last):
  File "/home/ramius/test.py", line 1, in <module>
    from pyvirtualdisplay import Display
ImportError: No module named 'pyvirtualdisplay'

Any idea why?

ah- you will have to pip install --user pyvirtualdisplay or install it into your virtualenv. We have it included/installed in python2.7 but not in python3.4

Hello, could you be more specific, Conrad.I have run pip install --user pyvirtualdisplay from bash but it does not work.

Sorry about that, there was a mistake in Conrad's post. For Python 3.4 you need to run

pip3.4 install --user pyvirtualdisplay

...unless you're in a virtualenv that's configured to use Python 3.4 only (in which case pip install pyvirtualdisplay is correct).

There's more information on this help page.

i am getting an error driver = webdriver.phantomjs("/home/naveenvalluru/node_modules/phantomjs/lib/phantom/bin/phantomjs") TypeError: 'module' object is not callable

can you please guide me..............

we don't support phantomjs... more info here: http://help.pythonanywhere.com/pages/selenium

Hello, fyi pyvirtualenv is still not included in the pyhon3.x versions. Just ran in to this very issue.

Do you mean pyvirtualdisplay? In that case, you are correct.