title: How do I import a python file through a path?
body: <p>I am trying to make it so when this runs it runs the newest version in the list.</p>
  <p>Here is the directory I want:</p>
  <pre><code>ClockOS:
     bootLoader.py (the file I am starting at)
     Versions:
        Version 0.1.1:
           main.py (Ignore because tis an older version)
        Version 0.1.2:
           main.py (The one I want to run/import)
  </code></pre>
  <hr />
  <p>I have tried loading  through <code>os.dir</code>, and using <code>sys.path</code>, and adding an empty <code>__init__.py</code>
  Anyone know how to get this working?
  My code:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  import re
  import sys
  
  versionList = []
  
  for filename in os.listdir('Versions'):
      if filename.startswith('Version'):
          versionList.append(filename)
          print(f&quot;Loaded {filename}&quot;)
  
  def major_minor_micro(version):
      major, minor, micro = re.search('(\d+)\.(\d+)\.(\d+)', version).groups()
  
      return int(major), int(minor), int(micro)
  
  latest = str(max(versionList, key=major_minor_micro))
  
  print(&quot;Newest Version: &quot;, latest)
  
  os.path.dirname('Versions/'+str(latest))
  
  
  sys.path.insert(1, latest)
  print(sys.path)
  
  
  
  import main
  </code></pre>
  <p>Lastly, I need this to work on both windows and linix, if that's possible.</p>