【发布时间】:2020-12-10 07:59:35
【问题描述】:
我的代码有什么问题?我可以在我的 vscode 上运行这个很好,但它不会在 heroku 上运行,问题来自这个代码
COGS = [path.split("\\")[-1][:-3] for path in glob("./lib/cogs/*.py")]
class Bot(BotBase):
def __init__(self):
self.PREFIX = PREFIX
self.ready= False
self.cogs_ready = Ready()
self.guild = None
self.scheduler = AsyncIOScheduler()
db.autosave(self.scheduler)
super().__init__(command_prefix=PREFIX, owner_ids=OWNER_IDS)
def setup(self):
for cog in COGS:
self.load_extension(f"lib.cogs.{cog}")
print(f"{cog} cog loaded")
print("setup complete")
我得到的错误是
2020-08-20T22:51:05.100470+00:00 app[Worker.1]: self.setup()
2020-08-20T22:51:05.100473+00:00 app[Worker.1]: File "/app/lib/bot/__init__.py", line 56, in setup
2020-08-20T22:51:05.100618+00:00 app[Worker.1]: self.load_extension(f"lib.cogs.{cog}")
2020-08-20T22:51:05.100621+00:00 app[Worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 660, in load_extension
2020-08-20T22:51:05.100910+00:00 app[Worker.1]: spec = importlib.util.find_spec(name)
2020-08-20T22:51:05.100913+00:00 app[Worker.1]: File "/app/.heroku/python/lib/python3.8/importlib/util.py", line 94, in find_spec
2020-08-20T22:51:05.101051+00:00 app[Worker.1]: parent = __import__(parent_name, fromlist=['__path__'])
2020-08-20T22:51:05.101070+00:00 app[Worker.1]: ModuleNotFoundError: No module named 'lib.cogs.'
2020-08-20T22:51:05.196203+00:00 heroku[Worker.1]: Process exited with status 1
2020-08-20T22:51:05.234805+00:00 heroku[Worker.1]: State changed from up to crashed
请帮忙
【问题讨论】:
标签: python heroku visual-studio-code discord discord.py