ModuleNotFoundError: No module named 'src.core'

Traceback (most recent call last):
File “”, line 3, in
from src.core.bot_app import start_app
ModuleNotFoundError: No module named ‘src.core’

Какая тут проблема?

Hi @exibexi , welcome to the forums!
Can you try entering pip install src.core into the Shell?

Oh, I see.
Can you add these lines of code:

from src import core
from core import file

I see that you are trying to import a file from the corefolder. Note that you’ll need to replace file with the name of the file.
Hope this helps!

1 Like

How can I add these lines to the code?

Hi @exibexi !
You can replace the lines from src.core.bot_app import start_app with the above 2 lines of code.

1 Like

Sorry for the stupidity, but I’ve been scratching my head over this error since morning.

@exibexi Ok, I’ve got it:

with open('src/core/' ):

Hope this helps!
Note: This was a nudge by ChatGPT, an AI. iT did not write this code, but I shortened it and adapted it. (I added a slash in my own idea, it removed it, making it work)

1 Like

The following error has appeared

Am I doing something wrong?

Try removing the with block from before, then run poetry remove src

1 Like

You should put files in src and src/core, and this will fix the problem. Then in, revert the code back to the original imports you used.
In python, never forget to put an file in all of your packages! This will help python more easily find your package.
Definitely don’t use open() as a way to import python files!

What caused the ModuleNotFoundError?
Checking a hidden directory .pythonlibs/lib/python3.10/site-packages, we see there is a different unrelated src package that python has been importing. This other package obviously doesn’t contain a core package, so an error occurs.
In the shell, we can easily debug the problem. This also showed in the error message in post 7.

import src
# home/runner/PricklyMiniatureCache/.pythonlibs/lib/python3.10/site-packages/src/

By adding an file to our src, python can ‘see’ it before the other src package (simplification).
Now it’s correct and everything works:

import src
# home/runner/PricklyMiniatureCache/src/