title: Chrome Native Messaging “Native host has exited.” on python 3rd party package import
body: <p>I'm working on a Chrome Extension that uses the native messaging feature to communicate with a Python script. As part of the Python script, I need to watch the file system, so I am pulling in <a href="https://github.com/gorakhargosh/watchdog" rel="nofollow">watchdog</a> as a third party dependency. I've installed this package using pip, both globally and using a virtualenv, and I am pulling in two classes with the following lines in my script:</p>
  
  <pre><code>from watchdog.events import PatternMatchingEventHandler
  from watchdog.observers import Observer
  </code></pre>
  
  <p>It's all very simple. Here's where it gets weird. If I run the script using python on the command line it runs fine. Also, if I launch Chrome from the command line with the following command:</p>
  
  <pre><code>/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
  </code></pre>
  
  <p>The native script is successfully invoked by the Chrome extension. However, if I launch Chrome normally (just clicking the Chrome application icon), I get the following error right on startup:</p>
  
  <pre><code>Native host has exited.
  </code></pre>
  
  <p>If I remove both of the watchdog import lines from my script it runs fine. I'm pretty stuck, as I don't seem to have a way of debugging the problem given that it works when I launch the script from the terminal.</p>