title: How to package tensorflow with pyinstaller on MacOSX?
body: <p>I am distributing a python program that contains tensorflow. On OSX, python 2.7, I have no errors loading libraries and running tensorflow. When using pyinstaller to create an executable it fails with a PBR error.</p>
  
  <p>We can reduce this problem down to a simple (hopefully reproducible) error.</p>
  
  <p>Here is our program. Let's just load tensorflow and have it print out some path info.</p>
  
  <p>tf_check.py</p>
  
  <pre><code>import tensorflow
  print(tensorflow.__file__)
  </code></pre>
  
  <p>Run with pyinstaller.</p>
  
  <pre><code>Bens-MacBook-Pro:tests ben$ pyinstaller tf_check.py 
  66 INFO: PyInstaller: 3.3
  66 INFO: Python: 2.7.10
  78 INFO: Platform: Darwin-16.7.0-x86_64-i386-64bit
  79 INFO: wrote /Users/ben/Documents/DeepMeerkat/tests/tf_check.spec
  87 INFO: UPX is not available.
  </code></pre>
  
  <p>Builds without a problem. Trying to run the tf_check under dist/tf_check/</p>
  
  <p>yields</p>
  
  <pre><code>Last login: Thu Sep 28 12:54:34 on ttys000
  Bens-MacBook-Pro:~ ben$ /Users/ben/Documents/DeepMeerkat/tests/dist/tf_check/tf_check ; exit;
  Traceback (most recent call last):
    File "tf_check.py", line 1, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/PyInstaller-3.3-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
      exec(bytecode, module.__dict__)
    File "tensorflow/__init__.py", line 24, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/PyInstaller-3.3-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
      exec(bytecode, module.__dict__)
    File "tensorflow/python/__init__.py", line 107, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/PyInstaller-3.3-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
      exec(bytecode, module.__dict__)
    File "tensorflow/python/platform/test.py", line 60, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/PyInstaller-3.3-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
      exec(bytecode, module.__dict__)
    File "mock/__init__.py", line 2, in &lt;module&gt;
    File "/Library/Python/2.7/site-packages/PyInstaller-3.3-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
      exec(bytecode, module.__dict__)
    File "mock/mock.py", line 71, in &lt;module&gt;
    File "pbr/version.py", line 461, in semantic_version
    File "pbr/version.py", line 448, in _get_version_from_pkg_resources
    File "pbr/packaging.py", line 755, in get_version
  Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.
  [1916] Failed to execute script tf_check
  logout
  Saving session...
  ...copying shared history...
  ...saving history...truncating history files...
  ...completed.
  Deleting expired sessions...9 completed.
  
  [Process completed]
  </code></pre>
  
  <p>Some system information</p>
  
  <pre><code>Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
  [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import tensorflow
  &gt;&gt;&gt; tensorflow.__version__
  '1.3.0'
  </code></pre>
  
  <p>The same code works on Windows without a problem. Again, only when distributing with pyinstaller. </p>
  
  <p>Can anyone show an example of packaging tensorflow on OSX?</p>
  
  <p>EDIT #1</p>
  
  <p>Following <a href="https://stackoverflow.com/questions/38777742/tensorflow-cuda-gtx-1070-import-error">Tensorflow CUDA GTX 1070 import error</a></p>
  
  <ul>
  <li><p>I tried installing in a clean virtual env, just pip install
  tensorflow and pip install pyinstaller, no improvement. </p></li>
  <li><p>I tried exporting the PBR version before bulding pyinstaller
  tf_check.py, no improvement.</p></li>
  </ul>
  
  <p><code>(env) Bens-MacBook-Pro:tests ben$ echo $PBR_VERSION
   3.1.1</code><br>
  <code>(env) Bens-MacBook-Pro:tests ben$ open dist/tf_check/tf_check</code></p>