$PYTHONPATH setup for running Alembic?

2,906 views
Skip to first unread message

junepeach

unread,
Nov 28, 2012, 3:27:56 PM11/28/12
to sqlal...@googlegroups.com
When using Alembic autogenerate command, we need to add a new module (mymodule) to $PYTHONPATH, and then configure env.py. $PYTHONPATH seems not stable. When I open an ubuntu terminal, and type: export PYTHONPATH=$PYTHONPATH:/home/mydir/mymodule, the new module is added into $PYTHONPATH variable. autogenerate command worked fine. But when I open a new ubuntun terminal, and check $PYTHONPATH, the new module mymodule was not there, and autogenerate command didn't work under this terminal. I don't know what is wrong.

Another problem I encountered: I am one of users in an Ubuntu OS, and I can use 'sudo bash' to get root permission. Another user, let us call usersupper, who installed alembic in that Ubuntu OS, but didn't configure it. I used root permission to configure it. THere is no problem to run 'alembic revision -m "create account table"', but failed to run 'alembic revision --autogenerate', and got error:
......
module = imp.load_source(module_id, path, open(path, 'rb'))
File "alembic/env.py", line 20, in <module>
from mymodule import myschema
ImportError: No module named mymodule

but I did run command 'export PYTHONPATH=$PYTHONPATH:/home/mydir/mymodule' successfully. Is that permission problem?

Please let me know if I didn't explain the problem clearly.
Thanks a lot in advance!

junepeach

unread,
Nov 28, 2012, 3:55:48 PM11/28/12
to sqlal...@googlegroups.com
at least I made a mistake for not creating a __init__ file under 'mymodule' dir.
Reply all
Reply to author
Forward
0 new messages