title: Getting Pyinstaller to recognize the path to Kivy Garden Matplotlib modules
body: <p>This is similar to: <a href="https://stackoverflow.com/questions/24048350/kivy-garden-in-pyinstaller-stuck-trying-to-trace-import">Kivy Garden in PyInstaller - stuck trying to trace import</a>  except that I'll provide much more detail to hopefully make this easier for someone to test out and provide a concrete solution....</p>
  
  <p>I've built a Python 2.7.13 application using Kivy 1.9.1 and am attempting to package it for Windows, within Windows 10, with Pyinstaller.  In short - I cannot get Pyinstaller to pick up the Garden modules - specifically the matplotlib module, which I am using to display data.  This garden module was installed via:</p>
  
  <pre><code>garden.bat install matplotlib
  </code></pre>
  
  <p>My application is far too large and complicated to post here, so I've found an example online to include which tries to import and use the module in essentially the same way that I'm doing it.  Here is the Python file, which works fine when ran from the Python interpreter:</p>
  
  <pre><code>import matplotlib
  matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')
  from matplotlib.figure import Figure
  from numpy import arange, sin, pi
  from kivy.app import App
  
  import numpy as np
  from matplotlib.mlab import griddata
  from kivy.garden.matplotlib.backend_kivy import FigureCanvas,\
                                              NavigationToolbar2Kivy
  
  from kivy.uix.floatlayout import FloatLayout
  from kivy.uix.boxlayout import BoxLayout
  from matplotlib.transforms import Bbox
  from kivy.uix.button import Button
  from kivy.graphics import Color, Line, Rectangle
  
  import matplotlib.pyplot as plt
  from matplotlib import cm
  from mpl_toolkits.mplot3d import Axes3D
  
  fig, ax = plt.subplots()
  
  X = np.arange(-508, 510, 203.2)
  Y = np.arange(-508, 510, 203.2)
  X, Y = np.meshgrid(X, Y)
  
  Z = np.random.rand(6, 6)
  
  plt.contourf(X, Y, Z, 100, zdir='z', offset=1.0, cmap=cm.hot)
  plt.colorbar()
  
  ax.set_ylabel('Y [mm]')
  ax.set_title('NAILS surface')
  ax.set_xlabel('X [mm]')
  
  canvas = fig.canvas
  
  
  
  def callback(instance):
  
      global fig, ax
  
      X = np.arange(-508, 510, 203.2)
      Y = np.arange(-508, 510, 203.2)
      X, Y = np.meshgrid(X, Y)
  
      Z = 1000*np.random.rand(6, 6)
      plt.clf()
      plt.contourf(X, Y, Z, 100, zdir='z', offset=1.0, cmap=cm.hot)
      plt.colorbar()
  
      canvas.draw()
  
  
  class MatplotlibTest(App):
      title = 'Matplotlib Test'
  
      def build(self):
          fl = BoxLayout(orientation="vertical")
          a = Button(text="press me", height=40, size_hint_y=None)
          a.bind(on_press=callback)
  
          fl.add_widget(canvas)
          fl.add_widget(a)
          return fl
  
  if __name__ == '__main__':
      MatplotlibTest().run()
  </code></pre>
  
  <p>Pyinstaller, as well as the Python interpreter, are put on my windows path, so when I pass the above file (named mplTest.py) to the Python interpreter via the Windows Powershell like</p>
  
  <pre><code>python mplTest.py
  </code></pre>
  
  <p>everything works like a charm.  However, the attempt to package this with the command:</p>
  
  <pre><code>pyinstaller mplTest.py
  </code></pre>
  
  <p>yields the ./dist/ and ./build/ directories as expected, along with a pyinstaller spec file.  If I navigate to the ./dist/mplTest/ directory and try to run the file mplTest.exe (the executable generated by pyinstaller), I get the following as a part of the log message:</p>
  
  <pre><code>[WARNING           ] stderr: Traceback (most recent call last):
  [WARNING           ] stderr:   File "mplTest.py", line 10, in &lt;module&gt;
  [WARNING           ] stderr: ImportError: No module named garden.matplotlib.backend_kivy
  </code></pre>
  
  <p>I've tried to modify the hidden_imports inside of the .spec file with:</p>
  
  <pre><code>hiddenimports=['garden.matplotlib.backend_kivy'],
  </code></pre>
  
  <p>but when trying to compile the .spec file with pyinstaller, I eventually get the line:</p>
  
  <pre><code>362 ERROR: Hidden import 'garden.matplotlib.backend_kivy' not found
  </code></pre>
  
  <p>Can someone please make a suggestion here?  One user in the linked SO thread mentioned using:</p>
  
  <pre><code>garden.bat install --app matplotlib
  </code></pre>
  
  <p>to create a ./libs/garden/ directory where these are installed, so maybe someone can show me how to link to these from within the spec file?</p>
  
  <p>I'm really beating my head against this one and it's painful to have put in so many development hours to be stuck on something that is probably so trivial....I'm happy to supply more information if necessary.</p>
  
  <p>Thanks in advance.</p>