title: Python cannot import from another file name not defined
body: <p>I am trying to import a custom function from another python file but keep getting an error <code>NameError: name 'testme' is not defined</code>. I confirmed that I am importing the file correctly according to <a href="https://stackoverflow.com/questions/31009668/python-cannot-import-name">this SO post</a> and that <a href="https://stackoverflow.com/questions/29843684/python-cannot-import-name">the function is top level</a>. What else can I try to fix this?</p>
  
  <p>My main python file is:</p>
  
  <pre><code>import sys
  import dbconn
  #from dbconn import testme #&lt;----did not work
  
  
  dev=True
  
  if(dev):
      categId='528'
      pollIds=[529,530,531]
  else:
      categId=str(sys.argv[1])
      pollIds=[529,530,531]
  
  
  df=testme(categIds)#callServer(categId,pollIds)
  df
  if(not categId.isdigit):
      print('categ id fail. expected digit got: '+categId)
  .....
  </code></pre>
  
  <p>and dbconn.py:</p>
  
  <pre><code>import pymysql #pip3 install PyMySQL
  import pandas as pd
  from scipy.stats.stats import pearsonr
  from scipy import stats
  
  def testme(categIds):
      try:
          df=categIds
      except Exception as e:
          print("broke")
      return categIds
  </code></pre>
  
  <p>Not sure if it makes a difference but I am running the main python file from within a Jupyter notebook, and have a compiled version of dbconn.py in the same directory</p>
  
  <p>In response to the suggestions I tried:</p>
  
  <pre><code>df=dbconn.testme(categIds) 
  </code></pre>
  
  <p>got the error:</p>
  
  <p><code>module 'dbconn' has no attribute 'testme'</code></p>