title: ImportError - attempted relative import with no known parent package
body: <p>It looks like to be a known problem and I am not the only one who encounter this issue. But none of the StackOverflow topics I've read helped me.</p>
  <p>So here is the tree of my folder:</p>
  <pre><code>.
  ├── Dockerfile
  ├── app
  │   ├── __init__.py
  │   ├── app.py
  │   ├── config.py
  │   ├── controllers
  │   │   └── home.py
  │   ├── models.py
  │   └── views
  │       └── home.py
  ├── database.conf
  ├── docker-compose.yml
  ├── jarvis.conf
  └── requirements.txt
  </code></pre>
  <p>As you can see I've tried to dockerized my app.</p>
  <p>Let's have a look to my Dockerfile and docker-compose.yml</p>
  <p><strong>Dockerfile:</strong></p>
  <pre><code>FROM python:3.6.8-alpine
  
  LABEL maintainer=&quot;Jordane * &lt;*&gt;&quot;
  LABEL version=&quot;1.0.0&quot;
  
  RUN apk add build-base postgresql-dev
  
  RUN pip install --upgrade pip
  COPY requirements.txt /
  RUN pip install -r requirements.txt
  
  COPY app/ /app
  WORKDIR /app
  
  CMD [&quot;gunicorn&quot;, &quot;-w 1&quot;, &quot;app:app&quot;, &quot;-b&quot;, &quot;0.0.0.0:3000&quot;]
  </code></pre>
  <p><strong>docker-compose.yml:</strong></p>
  <pre><code>version: '3.5'
  
  services:
  
    db:
      container_name: postgres
      image: postgres:11.2-alpine
      env_file: database.conf
      ports:
        - 5432:5432
      volumes:
        - dbdata:/var/lib/postgresql/data
  
    web:
      build: .
      container_name: flask
      restart: always
      env_file: 
        - jarvis.conf
        - database.conf
      environment:
        - PYTHONDONTWRITEBYTECODE=1
      ports:
        - 6876:3000
      volumes:
        - ./app/:/app
      depends_on:
        - db
  
  volumes:
    dbdata:
  </code></pre>
  <p>Here is the begin of my trouble I think</p>
  <p>I've wrote this <strong><strong>init</strong>.py:</strong></p>
  <pre><code>from flask import Flask
  import flask_sqlalchemy
  
  from .models import db
  from . import config
  
  def create_app():
      flask_app = Flask(__name__)
      flask_app.config['SQLALCHEMY_DATABASE_URI']= config.DB_CONN_URI
      flask_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
      flask_app.app_context().push()
      db.init_app(flask_app)
      db.create_all()
      return flask_app
  </code></pre>
  <p>and as you saw above in my <strong>Dockerfile</strong> I am running my app with gunicorn and run the app.</p>
  <p><strong>app.py:</strong></p>
  <pre><code>&quot;&quot;&quot; Jarvis slackBot v1.0 (api) &quot;&quot;&quot;
  
  __author__ = &quot;titus&quot;
  
  from flask import request, jsonify
  
  from . import create_app
  from .models import User, db
  
  from views.home import home_bp
  
  from loguru import logger
  
  app = create_app()
  # logger.add(&quot;app.log&quot;, rotation=&quot;500 MB&quot;)
  
  app.register_blueprint(home_bp, url_prefix='/home')
  </code></pre>
  <p>And here is the error :</p>
  <pre><code>flask  |     from . import create_app
  flask  | ImportError: attempted relative import with no known parent package
  </code></pre>
  <p>I've followed this Tutorial to help me: <a href="https://medium.com/@hmajid2301/implementing-sqlalchemy-with-docker-cb223a8296de" rel="nofollow noreferrer">https://medium.com/@hmajid2301/implementing-sqlalchemy-with-docker-cb223a8296de</a></p>
  <p>So it's supposed to work ...</p>
  <p>If I replace :</p>
  <ul>
  <li><code>from . import create_app</code> by <code>from __init__ import create_app</code></li>
  <li><code>from .models import User, db</code> by <code>from models import User, db</code></li>
  <li><code>from .models import db</code> by <code>from models import db</code></li>
  <li><code>from . import config</code>
  by <code>import config</code></li>
  </ul>
  <p>It works better, but I really feel like I am doing something wrong.</p>