How do I get a file to be recognized as a module in python
<p>Here is the situation. I created a directory structure as follows</p>

<p>pymaster<br>
----------file1.py<br>
pymaster2<br>
----------file2.py</p>

<p>Neither the pymaster1 nor pymaster2 directories are packages. That was intentional.</p>

<p>I set a variable x=1 in file1.py</p>

<p>In file2.py I did the following:</p>

<pre><code>import sys, os     
sys.path.append(os.path.realpath('..')) 
# this added the path to the pymaster directory to my system 
#path. I printed it out and it was added.

import pymaster  
print(file1.x)
</code></pre>

<p>I get the following error message:</p>

<blockquote>
  <p>Traceback (most recent call last):<br>
  File "file2.py", line 5, in 
      import pymaster ImportError: No module named pymaster</p>
</blockquote>

<p>Any suggestions?</p>
