mmatt
mmatt

Reputation: 41

Keep getting ModuleNotFoundError: No module named 'lib.cogs' error when trying to run my bot on an ubuntu server

Is this a code error, or something i forgot to install? Please help thank you!

Exact error:


Traceback (most recent call last):
  File "launcher.py", line 5, in <module>
    bot.run(VERSION)
  File "/root/doob/lib/bot/__init__.py", line 61, in run
    self.setup()
  File "/root/doob/lib/bot/__init__.py", line 47, in setup
    self.load_extension(f"lib.cogs.{cog}")
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 660, in load_extension
    spec = importlib.util.find_spec(name)
  File "/usr/lib/python3.8/importlib/util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'lib.cogs.'

Upvotes: 0

Views: 996

Answers (2)

mmatt
mmatt

Reputation: 41

it's because file structures work different on linux than Windows.

(how i fixed it, https://stackoverflow.com/a/63931191/12388205)

Upvotes: 0

unex
unex

Reputation: 1356

In your setup function you have f"lib.cogs.{cog}", but cog is an empty string or something, so its trying to essentially import lib.cogs. which is not a valid module / does not exist and is causing your error.

Upvotes: 1

Related Questions