Importing another project as modules in python
<p>Suppose I have a project in the following structure</p>

<pre><code>projectfoo/
|- mymodule/
|--|- __init__.py
|--|- library.py
|- preprocessor.py
</code></pre>

<p>and in the <code>__init__.py</code> in <code>mymodule</code> looks like this</p>

<pre><code>from . import library #library itself has other functions

def some_function():
    blar blar blar...
</code></pre>

<p>and the <code>preprocessor.py</code> would look like follows</p>

<pre><code>import mymodule

def main():
    something()

def something():
    mymodule.some_function() # calls the function defined in __init__.py

if __name__ == '__main__':
    main()
</code></pre>

<p>Then I started <code>projectbar</code>, which is using a lot of common code from <code>projectfoo</code>. So instead of copying and pasting code between projects, I wish to import <code>projectfoo</code> into project bar, as follows.</p>

<pre><code>projectbar/
|- projectfoo/
|--|- mymodule/
|--|--|- __init__.py
|--|--|- library.py
|--|- preprocessor.py
|- index.py
</code></pre>

<p>So I am trying to import <code>preprocessor</code> in my <code>index.py</code> as follows</p>

<pre><code>from projectfoo import preprocessor
</code></pre>

<p>However I am getting an error saying <code>preprocessor.py</code> is now unable to import <code>mymodule</code>.</p>

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

<p>Am I doing this correctly? I am using python3.4 running in ubuntu 14.04 in my setup.</p>

<p>EDIT: I also tried adding <code>__init__.py</code> to <code>projectfoo</code>, but I am still getting the same error</p>