Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myproject/
- common/
- __init__.py
- model.py
- alembic/
- env.py
- from .common import model
- SystemError: Parent module '' not loaded, cannot perform relative import
- . ← That's the root directory of my project
- ├── alembic.ini
- ├── dev-requirements.txt
- ├── requirements.txt
- ├── runtime.txt
- ├── setup.cfg
- ├── src
- │ └── models
- │ ├── base.py
- │ ...
- │ └── migrations
- │ ├── env.py
- │ ├── README
- │ ├── script.py.mako
- │ └── versions
- │
- └── tests
- import sys
- from os.path import abspath, dirname
- sys.path.insert(0, dirname(dirname(dirname(abspath(__file__))))) # Insert <.>/src
- import models # now it can be imported
- target_metadata = models.base.Base.metadata
- PYTHONPATH=. alembic revision -m "..."
- from src.models.base import Base
- import sys
- import os
- sys.path.insert(0, os.getcwd())
Add Comment
Please, Sign In to add comment