title: How to check syntax errors of a Python module with unknown imports
body: <p>I want to invoke the Python interpreter to check possible syntax errors of my module.<br>
  I can't do it because the interpreter generates an early error message of </p>
  
  <pre><code>ImportError: No module named Part
  </code></pre>
  
  <p>In my module I have imported a module that is needed in my code. </p>
  
  <pre><code>import Part
  
  def draw_circle(radius):
      myshape = Part.makeSphere(1)
      Part.show(myshape)
      return
  </code></pre>
  
  <p>The imported <code>Part</code> module belongs to FreeCAD in my case but my question is general.  Let's assume that we don't know the module library directory path of the module <code>Part</code>.</p>
  
  <p>When in FreeCAD I import my syntactically correct module everything runs without problems.</p>
  
  <pre><code>import sys
  sys.path.append('/home/mypathtomymodule')
  import mymodule
  
  mymodule.draw_circle(1)
  </code></pre>
  
  <p>There is no problem as long as I write proper syntax code. Unfortunately I don't always do that. In those cases my problem is that I can not search for the syntax errors in my module with the Python interpreter. Also the FreeCAD is not very helpful here, When I try to run the program in FreeCAD it gives an uninformative error message like </p>
  
  <pre><code>NameError: name 'badcode' is not defined
  </code></pre>