title: PyQt5 GUI - exe made with PyInstaller doesn't open
body: <p>I've got a GUI which runs perfectly fine when I execute it from the Anaconda Prompt. I get the following window as output:</p>
  
  <p><a href="https://i.stack.imgur.com/J0yuT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0yuT.png" alt="enter image description here"></a></p>
  
  <p>I have installed pyinstaller using pip, and have then run the line</p>
  
  <pre><code>pyinstaller.exe --onefile [my file path]\mytest.py
  </code></pre>
  
  <p>with my actual file path instead of <code>[my file path]</code>. This creates a file called 'mytest.exe'. </p>
  
  <p>However, when I double-click on it, all that happens is that a black window is shown for about 5 seconds, then I get this message for a split second:</p>
  
  <p><a href="https://i.stack.imgur.com/PKeEn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PKeEn.png" alt="enter image description here"></a></p>
  
  <p>The window that the Python script makes is never shown (unlike when I directly execute the Python script).</p>
  
  <p>Here's the code:</p>
  
  <pre><code>from PyQt5.QtWidgets import *
  from PyQt5.QtCore import *
  from PyQt5.QtGui import *
  
  import sys
  
  from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
  from matplotlib.figure import Figure
  
  import matplotlib.pyplot as plt
  import numpy as np
  
  
  class LineBuilder:
      def __init__(self, ax):
          self.ax = ax
          self.on = 1
          self.lastline, = self.ax.plot([0],[0])
          self.cid = ax.figure.canvas.mpl_connect('pick_event', self)
  
      def __call__(self, event):
          self.on *=-1
          thisline = event.artist
          xdata = thisline.get_xdata()
          ydata = thisline.get_ydata()
          ind = event.ind
          print(xdata[ind])
          print('modified',xdata[ind][0])
          self.lastline.remove()
          self.lastline=self.ax.axvline(x=xdata[ind][0])
          self.ax.figure.canvas.draw()
  
  class View(QGraphicsView):
  
      def __init__(self):
          super(View, self).__init__()
  
          self.initScene(5)
  
      def initScene(self,h):     
  
          self.scene = QGraphicsScene()
          self.figure = plt.figure()
          self.canvas = FigureCanvas(self.figure)
          self.figure.subplots_adjust(left=0.03,right=1,bottom=.1,top=1,wspace=0, hspace=0)
  
          ax = self.figure.add_subplot(111)
          ax.set_xlim([0,1000])
          data = np.random.rand(1000)
          ax.plot(data, '-') 
  
          self.canvas.draw()
          self.setScene(self.scene)
          self.scene.addWidget(self.canvas)
  
  class MainWindow(QMainWindow):
  
      def __init__(self):
          super(MainWindow,self).__init__()
  
          self.setGeometry(150, 150, 700, 550) 
  
          self.view = View()
          self.view.setGeometry(0,0,self.width()*2,500)
          self.view.canvas.setGeometry(0,0,self.width()*2,500)        
  
          self.setCentralWidget(self.view)
  
  app = QApplication(sys.argv)
  
  window = MainWindow()
  window.show()
  
  app.exec_()
  </code></pre>
  
  <p>What should I change so that the .exe file actually opens the window? Is this even possible? The end goal is to create a GUI that runs without the end user needing to install Anaconda or anything related to Python.</p>