python package error when running from sublime
<p>I installed the python package <code>isochrones</code> using <code>pip install isochrones</code>.</p>

<p>When I type <code>from isochrones.dartmouth import Dartmouth_Isochrone</code> in the <code>Sublime text editor</code> I get the following error:</p>

<pre><code>from isochrones.dartmouth import Dartmouth_Isochrone
ImportError: No module named dartmouth
</code></pre>

<p>However, the same command works when I run it from <code>ipython</code>. </p>

<p>What's going on?! I have a long code, so working in <code>ipython</code> is not possible. I want to use <code>sublime</code>.</p>

<p>You need to create a new <a href="http://docs.sublimetext.info/en/latest/file_processing/build_systems.html" rel="nofollow">build system</a> for Anaconda. Select <strong><code>Tools â Build System â New Build System...</code></strong> and replace the contents of the file that opens with the following:</p>

<pre class="lang-js prettyprint-override"><code>{
    "cmd": ["/Applications/anaconda/bin/python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}
</code></pre>

<p>When you hit save, it should automatically open your User directory (<code>~/Library/Application Support/Sublime Text 2/Packages/User</code>). Save the file there as <code>Anaconda Python.sublime-build</code>. Finally, select <strong><code>Tools â Build System â Anaconda Python</code></strong> so the proper system will run when you select Build.</p>

<p>Now that the build system is all set up, you need to ensure that you're installing things under the right Python distribution. OS X comes with Python built-in as <code>/usr/bin/python</code>, with system packages residing in a range of possible directories, depending on which build of OS X you're using. From the command line, run</p>

<pre><code>which pip
</code></pre>

<p>to ensure it points to the Anaconda installation. If it doesn't, you'll have to alter your <code>PATH</code> variable to put <code>/Applications/anaconda/bin</code> at the front, before <code>/usr/bin</code> and <code>/usr/local/bin</code>. How to do that is beyond the scope of this answer, but it's easy to find out by a quick Google search.</p>

<p>You should now be able to use your Anaconda <code>pip</code>-installed packages with Sublime Text.</p>

python python-2.7 sublimetext2 anaconda