0

When I try to run Pyperclip on AWS cloud9, I get the following error I get the following error

import pyperclip
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from pyvirtualdisplay import Display

display = Display(visible=0, size=(1280, 1024))
display.start()

pyperclip.copy("HELLO!! WORLD!!")
print(pyperclip.paste())

display.stop()

Pyperclip could not find a copy/paste mechanism for your system.

I've also installed xclip, see below. How can I install xclip on an EC2 instance?

>pip list
pyperclip 1.8.1

>yum list installed
xclip.x86_64 0.12-1.el6 @epel

GUI environment is also available in Xvfb. Please let me know how I can run Pyperclip.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
dai
  • 1
  • 1

1 Answers1

0

You need to import the pyperclip module after creating the display, as this module checks for it during initialization.

Like this:

from pyvirtualdisplay import Display

display = Display(visible=False, size=(1280, 1024))
display.start()

import pyperclip

pyperclip.copy("HELLO!! WORLD!!")
print(pyperclip.paste())

display.stop()