Why tkinter module raises attribute error when run via command line but not when run via IDLE?
<p><strong>Is there a reason why the code will raise an error when run via the command line compared to when run via IDLE's <code>run module f5</code> command?</strong></p>

<p>Recently I've been trying to improve the readability and robust-ness of my code. As a result I've been trying to remove all the <code>from module import *</code> lines. I used to use <code>from tkinter import *</code> and this line of my code worked perfectly fine:</p>

<p><code>self.path = filedialog.askdirectory()</code></p>

<p>But now I have changed <code>from tkinter import *</code> to <code>import tkinter as tk</code> and I have changed the code accordingly:</p>

<p><code>self.path = tk.filedialog.askdirectory()</code></p>

<p>A file called GUI.py imports this file with: <code>from lib.filesearch import *</code> (the line of code I mentioned resides within the filesearch file.)</p>

<p>I run my code via IDLE and everything is fine. My GUI still works and the line <code>self.path = tk.filedialog.askdirectory()</code> works like normal however, when I run the code through windows command line I get the error:</p>

<pre><code>AttributeError: 'module' object has no attribute 'filedialog'
</code></pre>

<p>Here are the relevant bits from my code:</p>

<p>From filesearch.py</p>

<pre><code>import tkinter as tk
    def get_path(self):
        """Store user chosen path to search"""
        self.paths = tk.filedialog.askdirectory(initialdir = FileSearch.DEFAULT)
        return self.paths
</code></pre>

<p>From GUI.py</p>

<pre><code>from lib.filesearch import *    
    def Browse(self):
        self.BrowseB['state']='disabled'
        self.p=self.CrawlObj.get_path()
        self.AddText('Searching from Path: ' + str(self.p))
        self.BrowseB['state']='normal'
</code></pre>

<p>Unlike this <a href="https://stackoverflow.com/questions/9072737/why-is-this-module-not-being-found-when-i-run-the-script-but-is-in-the-interpret?rq=1">question</a> I only have one version of python installed. Namely, Python34.</p>