PyQt5 Could not connect to display


to learn python I decided to make a small GUI that will interact with a web API. So without much thinking I created a virtual machine with Vagrant (ubuntu/trusty64) and installed PyQt5. I made a small script to create a window (here it is)

import sys from PyQt5 import QtWidgets app = QtWidgets.QApplication(sys.argv) main_window = QtWidgets.QMainWindow() main_window.show() sys.exit(app.exec_())

When I executed my script I ended up with this error


QXcbConnection: Could not connect to display


So I guess the problem comes from the fact that I'm using a virtual-machine without a display. Isn't there a way to make it use my Windows display just to render my program? Or do I need to install a VM with virtualbox?

Thanks for your time.


When provisioning your VM with Vagrant, you may specify to boot to GUI, such as:

config.vm.provider "virtualbox" do |v| v.gui = true end

More information <a href="https://docs.vagrantup.com/v2/virtualbox/configuration.html" rel="nofollow">here</a>

This will then launch the Qt app, using the VM's display.


  • PyQt5 Could not connect to display
  • Unix awk scripting to convert columns to rows
  • Bind a tkinter widget to a function containing args - Use of Lambda
  • XML to JSON Transformation in XSLT 3.0 [closed]
  • Circular dependencies with headers. Using #ifndef and #define
  • Qt5 Matplotlib Designer Plugin
  • VTK with Qt5 - Timer stops running when window is interacted with
  • Can't start designed pyQt application
  • Issue with fitInView of QGraphicsView when ItemIgnoresTransformations is on
  • Pygame error: mixer system not initialized
  • “Module use of python34.dll conflicts with this version of Python”
  • Having a relative path in a module relative to the file calling the module
  • How to send None with Signals across threads?
  • How do I configure context broker accept post requests from my remote sensor?
  • Alert pop up with LWUIT
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • DomPDF {PAGE_NUM} not on first page
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • Javascript simulate pressing enter in input box
  • Can I make an Android app that runs a web view in Chrome 39?
  • Updated Ionic CLI but shows previous version (Windows)
  • Importing jscolor library in angular 2
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • Comma separated Values
  • A cron job substitute?
  • Python: how to group similar lists together in a list of lists?
  • AngularJs get employee from factory
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Busy indicator not showing up in wpf window [duplicate]