Getting error using Tkinter in python on mac OS X
<p>I tried to run a nltk code for drawing parse trees. I got the error that tkinter module is not installed.</p>

<p>These are the error messages I got:</p>

<pre><code>1. UserWarning: nltk.draw package not loaded (please install Tkinter library).
   warnings.warn("nltk.draw package not loaded")

2. import _tkinter # If this fails your Python may not be configured for Tk
   ImportError: No module named _tkinter
</code></pre>

<p>After some searches I installed the ActiveTcl 8.5.18.0 using this <a href="https://www.python.org/download/mac/tcltk/" rel="nofollow">instructions</a>.</p>

<p>But when I try to run my code I still get the sam error. I tried </p>

<pre><code>import Tkinter
</code></pre>

<p>but I get the second error message above again.</p>

<pre><code>File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in &lt;module&gt;
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
</code></pre>

<p>I also looked at Tkinter documentations and it is mentioned that the correct installation of Tkinter can be verified by running the following command which again gives me another error.</p>

<pre><code>command: python -m tkinter
error: /usr/local/opt/python/bin/python2.7: No module named tkinter
</code></pre>

<p>I found this answers on Stackoverflow for my problem but they are either not very clear or not applicable to my case.</p>

<ol>
<li><p><a href="http://stackoverflow.com/questions/11752174/how-to-get-tkinter-working-with-ubuntus-default-python-2-7-install">How to get tkinter working with Ubuntu&#39;s default Python 2.7 install?</a>
Problems: tk-dev is not available for OS X (it is same as ActiveTcl) and I couldn't figure out how to rebuilt my python using make</p></li>
<li><p><a href="http://stackoverflow.com/questions/5459444/tkinter-python-may-not-be-configured-for-tk">Tkinter: &quot;Python may not be configured for Tk&quot;</a>
Problems: very vague. I don't know what should I do</p></li>
</ol>

<p>please help.</p>

<p>You should install ActivePython rather than ActiveTcl, and use it as your preferred Python. </p>

<p>The problem is your Python install isn't picking up your Tcl install, and the simplest way to solve that is to install a Python version that is configured for Tk, which ActivePython is: <a href="http://www.activestate.com/activepython" rel="nofollow">http://www.activestate.com/activepython</a></p>

<p>The issue is that the _tkinter Python module is not installed in your build, which is a required bridge between Python and Tk. You will have to reinstall nltk and any other packages you are using, unfortunately, as the versions you have will be installed for your current Python and not your new one.</p>

python osx python-2.7 tkinter activetcl