0

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?

Aledlp5
  • 53
  • 7
  • I tried by replicating your folder structure, but I don't get any errors. – Ajeet Verma Feb 25 '23 at 16:39
  • Actually, the problem shows up just when I run the program. The editor does not show any error, on the contrary, it can find the references in the other files. That's why I cannot figure out what's the matter – Aledlp5 Feb 25 '23 at 16:53

1 Answers1

1

#/consts/init.py


#this module include from consts
from . Key import Values

#main.py


from consts import Values

more information here

Promaster
  • 38
  • 4