I would guess this is a side effect of something that occurs in your env.py 
script.   Not all commands load env.py, so if your migration files depend on 
env.py being loaded in order for their imports to work that would be what’s 
happening here.

   

On Aug 11, 2014, at 8:21 PM, Anton <[email protected]> wrote:

> I have a flask application. My project tree looks like:
> .
> ├── Procfile
> ├── README.md
> ├── alembic
> ├── alembic.ini
> ├── my_app
> ├── requirements.txt
> ├── start_server.py
> └── venv
> 
> Where my_app contains Flask application, for some reason branches command 
> fails to run with an error ImportError: No module named my_app.types
> Traceback (most recent call last):
>   File "/Users/anton/dev/my_app/venv/bin/alembic", line 9, in <module>
>     load_entry_point('alembic==0.6.5', 'console_scripts', 'alembic')()
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py", 
> line 298, in main
>     CommandLine(prog=prog).main(argv=argv)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py", 
> line 293, in main
>     self.run_cmd(cfg, options)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py", 
> line 279, in run_cmd
>     **dict((k, getattr(options, k)) for k in kwarg)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/command.py",
>  line 200, in branches
>     for sc in script.walk_revisions():
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py", 
> line 81, in walk_revisions
>     heads = set(self.get_heads())
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py", 
> line 288, in get_heads
>     for script in self._revision_map.values():
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/util.py", 
> line 268, in __get__
>     obj.__dict__[self.__name__] = result = self.fget(obj)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py", 
> line 213, in _revision_map
>     script = Script._from_filename(self, self.versions, file_)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py", 
> line 496, in _from_filename
>     module = util.load_python_file(dir_, filename)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/util.py", 
> line 212, in load_python_file
>     module = load_module_py(module_id, path)
>   File 
> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/compat.py", 
> line 58, in load_module_py
>     mod = imp.load_source(module_id, path, fp)
>   File "alembic/versions/213495jl1br_.py", line 39, in <module>
>     from my_app.types import DbType
> ImportError: No module named my_app.types
> 
> Other commands like upgrade or revision --autogenerate work fine.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to