tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
820 stars 94 forks source link

又见 No module named 'xxx' #189

Closed h25302 closed 3 years ago

h25302 commented 3 years ago

之前出过类似毛病:https://github.com/tortoise/aerich/issues/164 ,并且在0.5.4版本中已解决。 今天升级0.5.6版本,在使用 aerich init-db时,又出现错误:

Error: Error while importing configuration module: No module named 'xxx'

经过跟踪分析,发现在utils.py文件第66行 importlib.import_module(config_path) 之前并未在sys.path加入配置目录

在cli.py文件第73行之前插入以下代码可解:

add_src_path(src_folder)

并且在ini配置文件中已加入配置: src_folder = ./.

我自己是暂时这样解决,不知道算不算BUG,望 @long2ice 尽快看下

h25302 commented 3 years ago

不太懂如何才能贡献代码,只能发文字了,抱歉抱歉 @long2ice

h25302 commented 3 years ago
72        src_folder = parser[name].get("src_folder", CONFIG_DEFAULT_VALUES["src_folder"])
73        add_src_path(src_folder)         <-----------------增加这一行
74        tortoise_config = get_tortoise_config(ctx, tortoise_orm)
long2ice commented 3 years ago

是哪一个命令?我这边测试没这个问题

h25302 commented 3 years ago

是哪一个命令?我这边测试没这个问题

https://github.com/tortoise/aerich/issues/188 里所出现的应该也是这个问题

我昨天试过 aerich init-db、aerich history都有问题,估计别的命令应该也有问题的

另外说下,我的环境也是windows的,不清楚是不是跟操作系统有关,没有具体分析 只是在 https://github.com/tortoise/aerich/issues/188 中,楼主也是win环境

long2ice commented 3 years ago

已修复,安装最新源码试试

injectionsuccesfully commented 3 years ago

Please refresh pypi (module not found)

h25302 commented 3 years ago
pip install git+https://github.com/tortoise/aerich.git@dev

安装dev版本后,测试了history、init-db、migrate,都已正常执行了。

long2ice commented 3 years ago

released