title: Python Relative Path - ModuleNotFoundError
body: <p>I need to pickle a python class I have instantiated and therefore need to use relative paths. I am using Python Version 3.6.6. Here is an example of how the project structure and code looks like:</p>
  
  <pre><code>modelling/
      test.py
      mod1/
          __init__.py
          classic_mod.py
  </code></pre>
  
  <p><strong>init</strong>.py</p>
  
  <pre><code>from .classic_mod import classic
  </code></pre>
  
  <p>classic_mod.py</p>
  
  <pre><code>class classic:
  
      def __init__(self, input_string):
          self.input_string = input_string
          print(self.input_string)
  
      def log_info(self):
          print(self.input_string)
  </code></pre>
  
  <p>test.py</p>
  
  <pre><code>from .mod1 import classic_mod
  from sklearn.externals import joblib
  
  model = classic_mod.classic("Hello World!")
  joblib.dump(model, "model.pkl")
  </code></pre>
  
  <p>If I use absolute paths I get problems when I load the pickle file into python in another folder. When I run test.py I get an error saying:</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 2, in &lt;module&gt;
      from .mod1 import classic_mod
  ModuleNotFoundError: No module named '__main__.mod1'; '__main__' is not a package
  </code></pre>
  
  <p>How can I solve this import error and at the same time pickle the class so I can use somewhere else?</p>