title: Tkinter Exception in Tkinter callback Traceback (most recent call last):
body: <p>I'm new to tkinter and I've looked online for help with this but can't find it. I cannot seem to find the error in my code, it points to a function in my main python file yet that function is clearly defined. I have attached pictures of the error message alongside the call to the fucntion and file that follow up in the error message.</p>
  <p>I can't seem to figure out what the problem is, Seems the error comes from when the user uploads a file into the program by clicking the button whihc triggers the UploadAction function in the tkinter file, which then goes on to call the read_f fucntion defined in the main python file. I'm importing the right files and the fucntion main.read_f is defined in the main python file. Not sure what's causing this?</p>
  <p>Note: The code randomly decides to work sometimes and will not display an error, yet seemingly randomly do so.</p>
  <p>Any help or a point in the right direction would be appreciated!</p>
  <p>Thanks</p>
  <p>The Error Message:</p>
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py&quot;, line 1702, in __call__
      return self.func(*args)
    File &quot;c:/Users/ripta/Desktop/CODING/CSV_Upload/tk_app.py&quot;, line 9, in UploadAction     
      main.read_f(filename)
    File &quot;c:\Users\ripta\Desktop\CODING\CSV_Upload\main.py&quot;, line 9, in read_f
      brand = search_tm.get_brand(prod_page)
    File &quot;c:\Users\ripta\Desktop\CODING\CSV_Upload\search_tm.py&quot;, line 17, in get_brand    
      page = prod_class.prod_page(link)
    File &quot;c:\Users\ripta\Desktop\CODING\CSV_Upload\prod_class.py&quot;, line 39, in __init__    
      with urllib.request.urlopen(req) as request_page:
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 223, in urlopen
      return opener.open(url, data, timeout)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 532, in open
      response = meth(req, response)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 642, in http_response
      'http', request, response, code, msg, hdrs)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 564, in error
      result = self._call_chain(*args)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 504, in _call_chain
      result = func(*args)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 735, in http_error_302
      new = self.redirect_request(req, fp, code, msg, headers, newurl)
    File &quot;C:\Users\ripta\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py&quot;, 
  line 673, in redirect_request
      raise HTTPError(req.full_url, code, msg, headers, fp)
  urllib.error.HTTPError: HTTP Error 307: Temporary Redirect
  </code></pre>
  <p>The Tkinter file:</p>
  <pre><code>import tkinter as tk
  import main
  from tkinter import filedialog
  from tkinter.constants import X, Y
  
  def UploadAction(event=None):
      filename = filedialog.askopenfilename()
      print('Selected:', filename)
      main.read_f(filename)
  
  root = tk.Tk()
  root.title('Sticker TM')
  root.geometry('350x350')
  root.iconbitmap('C:/Users/ripta/Desktop/CODING/CSV_Upload/trademark_icon.ico')
  T = tk.Text(root, height=1, width=35)
  T.pack()
  T.insert(tk.END, &quot;Make sure the file is not open&quot;)
  
  button = tk.Button(root, text='Select CSV file', command=UploadAction)
  button.pack(side='bottom', pady= '150')
  
  root.mainloop()
  </code></pre>
  <p>The main python file:</p>
  <pre><code>import trademarkia_scrap
  import file_upload
  import search_tm
  import pandas as pd
  from pandas.io.parsers import read_csv
  def read_f (given_file):
      df = pd.read_csv(given_file)
      prod_page = file_upload.links(df)
      brand = search_tm.get_brand(prod_page)
      split = search_tm.split_brand(brand)
      url_end = search_tm.get_url(split)
      tm_link = search_tm.get_tm_url_link(url_end)
      reg = trademarkia_scrap.get_reg_status(tm_link)
      print(reg)
      df[&quot;TradeMark&quot;] = reg
      df.to_csv(given_file)
      print('Done')
  </code></pre>