Python Import Error - specific case
<p>I know there has been a ton of questions about this, but mine is pretty specific and i don't really know why the import is not working. 
I've got the following Folder Structure:</p>

<pre><code>importmodule
-classes
-pluginhelper
-- __init__.py

-plugins
-- plugin_a
-- plugin b
-- ..

-__init__.py
-&lt;other py files&gt;
</code></pre>

<p>In my plugin files i am importing the pluginhelper like this: </p>

<pre><code>from importmodule.pluginhelper import function1, function2, ...
</code></pre>

<p>The functions are defined in the __ init __.py </p>

<p>Executing my plugin files works great on my windows machine. When i do it on the server, i get following Exception: </p>

<pre><code> ImportError: No module named 'importmodule'
</code></pre>

<p>The curious thing is, that i do get the error from every plugin, but one. In one of the plugins the import works, while there is no difference in the import statements.</p>

<p>I am using python 3.5 on both machines, while on the server my application is within a docker container.</p>

<p>Edit: 
Setting the sys.path didnt work either : </p>

<pre><code>  print("Indexed Path for Package.")
  sys.path.index(os.getcwd())
</code></pre>

<p>I found the possible problem: 
<strong>The folder structure in my dockercontainer seems to be different. I will fix it and tell you if it helped.</strong> Still i don't understand why it works with the one plugin using the same statement.</p>

<p>I want to share my solution with you, since anybody reading the question seems to have similar problems. </p>

<p>The problem occured because the package werent included in pythonpath / syspath. I am calling the plugins in a new thread with a script called execute.py. This is called via cmd from the main.py because i can't multiprocess my classes. And since the plugins are located in ../plugins, python only includes this path. Not the /importmodule path. Somehow it seems that it has been included on windows, i dont really know what has happened there tbh. </p>

<p>What i did was, i included the <code>sys.path.append</code> stuff on my execute.py which executes the plugins as follows: <code>from pluginhelper import scrapeHostnames, hostnamesToIps, getSource</code>. My IDE marks the import statement red now, but it is working, since i am appending the package.</p>

python importerror