title: PyInstaller - How do you handle environmental variables?
body: <p><strong>Background:</strong></p>
  
  <p>I am trying to convert a python script to an executable file that can be used on other computers. I decided to use PyInstaller. I am using <em>Python 2.7.13</em>/<em>Anaconda 2.2.0 (64-bit)</em>. I have of course seen many examples and I can achieve this for basic examples. However, the script I am now working on uses environmental variables. The following block of code appears at the start of my python script:</p>
  
  <pre><code>import os
  # force qt4
  os.environ['ETS_TOOLKIT'] = 'qt4'
  os.environ['QT_API'] = 'pyqt'
  
  from traits.api import HasTraits, Range, Instance, Button, on_trait_change, Bool, Str, Enum, Float, Int
  from traitsui.api import View, Item, Group, HGroup, spring, Handler, Action, InstanceEditor, Menu, MenuBar, message, \
      Tabbed
  from mayavi.core.ui.api import MayaviScene, SceneEditor, MlabSceneModel
  from pyface.api import FileDialog, OK
  import yaml
  from mayavi import mlab
  import numpy as np
  from collections import namedtuple
  import gdal
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>Running <code>pyinstaller --onefile filename.py</code> on the command line produces an <code>.exe</code>, but it doesn't run because of the error: <code>ImportError: No module named qt4</code>."qt4" isn't a module, so I am assuming the problem is with the line " <code>os.environ['ETS_TOOLKIT'] = 'qt4</code>'".
   After looking at various questions related to PyInstaller, I know how to use 'hiddenimports', but I have no idea how to handle environmental variables. Obviously something like <code>pyinstaller --onefile --hidden-import qt4 filename.py</code> didn't work.</p>