title: Python 3 - importing .py file in same directory - ModuleNotFoundError: No module named '__main__.char'; '__main__' is not a package
body: <p>I'm using Python 3.6 on Windows 10.  I have 2 .py files in the same directory, <code>char.py</code>, and <code>char_user.py</code>, as follows:</p>
  
  <p>char.py:</p>
  
  <pre><code># char.py
  
  import cv2
  
  #######################################################################################################################
  class Char:
  
      # constructor #####################################################################################################
      def __init__(self):
          self.contour = None
          self.centerOfMassX = None
          self.centerOfMassY = None
      # end def
  
  # end class
  </code></pre>
  
  <p>char_user.py:</p>
  
  <pre><code># char_user.py
  
  import os
  import cv2
  
  # I've tried this various ways, see more comments below
  from .char import Char
  
  #######################################################################################################################
  def main():
  
      char = Char()
  
      char.centerOfMassX = 0
      char.centerOfMassY = 0
  
      print("finished main() without error")
  # end main
  
  #######################################################################################################################
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>No matter what I try, on the line in <code>char_user.py</code> where I'm attempting to import file char.py, class Char, I get the error:</p>
  
  <pre><code>ModuleNotFoundError: No module named '__main__.char'; '__main__' is not a package
  </code></pre>
  
  <p>Here are some of the ways I've tried the import statement in <code>char_user.py</code>:</p>
  
  <pre><code>from .char import Char
  from . import Char
  import Char
  import char
  </code></pre>
  
  <p>I've tried both with and without an empty <code>__init__.py</code> in the same directory.</p>
  
  <p>I've consulted these posts but none have been able to provide a resolution:</p>
  
  <p><a href="https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory">How to import the class within the same directory or sub directory?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/41816973/modulenotfounderror-what-does-it-mean-main-is-not-a-package">ModuleNotFoundError: What does it mean __main__ is not a package?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/45446418/modulenotfounderror-no-module-named-main-xxxx-main-is-not-a-packag">ModuleNotFoundError: No module named &#39;__main__.xxxx&#39;; &#39;__main__&#39; is not a package</a></p>
  
  <p>This is the 1st time in Python 3 I've attempted to import a script that I wrote in the same directory (done this many times in Python 2 without concern).</p>
  
  <p>Is there a way to do this?  What am I missing?</p>