Custom module not found python

Question:

I’m building a simple telegram bot and i need to create many .py files to order the project but when I try to run the code, the terminal displays this error message:

    from consts.Key import Values
ModuleNotFoundError: No module named 'consts'

The project folder is structured like this:

|
|__ main.py
|__ basics
  |
  |__ consts
  |  |__ __init__.py
  |  |__ Key.py
  |
  |__ games
  |  |
  |  |__ __init.py
  |  |__ FindTheNumberGame.py
  |
  |__ __init__.py
  |__ StartApp.py

I have already read this question but it does not work still.

I need to import the Key module in StartApp.py to use the bot token and now I’m doing it in this way:

from consts.Key import Values

In this line, Values is a class that extends the Enum class.

Anyone can help?

Asked By: Aledlp5

||

Answers:

#/consts/init.py


#this module include from consts
from . Key import Values

#main.py


from consts import Values

more information here

Answered By: Promaster