title: Dynamically importing repository after running setup.py
body: <h2>The Problem</h2>
  
  <p>I have a Python script that runs in the background. At some point the script tries to import a module: <code>import mymodule</code>.</p>
  
  <p>Before the import line is executed in the Python script, another bash script (successfully) installs <code>mymodule</code> by running <code>python setup.py install</code>. </p>
  
  <p>The problem is that <code>import mymodule</code> in the Python script is not working because <code>mymodule</code> is not found, even though it's installed.</p>
  
  <h2>My solution</h2>
  
  <p>I checked <code>sys.path</code> before installing <code>mymodule</code> and after I saw that a new line had been added: <code>/usr/lib/python2.7/dist-packages/mymodule-1.0py.egg</code>. So before the line importing the module I added the line <code>sys.path.append("/usr/lib/python2.7/dist-packages/mymodule-1.0py.egg")</code>.</p>
  
  <p>My question is whether there is a better, less hardcoded way to solve the problem.</p>