I was recently assisting a QA engineer with some #Fun™ problems on Jenkins where tests running pyautogui (running under Python 2.7) were failing because pyautogui was not installed. Every time we attempted to pip install pyautogui it would give an error similar to the following:

Ensure you have the following packaged installed: xserver-xorg, python-pip, python-xlib, xfce4 (you can use a different desktop env such as Gnome or KDE), and xauth.sudo apt-get install -y xserver-xorg python-pip python-xlib xfce4 xauth
Also ensure that once you’ve install pip that you upgrade pip by running the following:pip install --upgrade pip
Open a GUI session either through xrdp (if installed) or console. Once you are here run the following command:echo $DISPLAY
Open an SSH connection to the server and set the $DISPLAY environment variable to match the output of the command above, in my case it was :10.0export DISPLAY=:10.0
You can confirm this value is set by running the echo command again. Once this is in place run the following to install pyautoguipip install pyautogui

Other Errors
If you receive any other errors around xauth or xserver try purging and reinstalling the packages above. You may also need to install a few other pip packages such as pillow and xlib.

Convert ISO to IMG Format

Once you’ve downloaded your ISO to your machine you will want to open terminal and cd to the directory. Once you’ve done this you’ll want to run the following commands (substituting your path):

hdiutil convert -format UDRW -o /path/to/target.img /path/to/source.iso
Once you’ve done this you’ll want to remove the .dmg extension by running the following (replacing the path with your path)mv /path/to/target.img.dmg /path/to/target.img

DD the IMG to USB Stick

Next we’ll use the Unix dd command to block copy the img file to the USB. Pay attention to the size of your flash drive when doing these steps as you can cause yourself some headache if you aren’t careful.

diskutil list

Note the path to your drive and proceed to unmount it from the terminal (replacing # with the disk number for your USB stick):diskutil unmountDisk /dev/disk#

Next we’ll use the dd command specifying the input file (if) which is your img file, and output file (of) which is the path to your USB flash drive, and specify block size (bs). Again where # is a placeholder for the disk number of your USB stick.sudo dd if=/path/to/downloaded.img of=/dev/rdisk# bs=1m