Modules and packages in python

0

Given my inexperience with languages and my lack of deepening on topics such as modules and packages in Python I came across a problem that is:

  

Traceback (most recent call last):     File "Main.py", line 1, in       from Menu.Menu import *     File "C: \ Users \ gero \ Desktop \ Programming \ Re-make TP [Python] \ Menu \ Menu.py", line 2, in       from menu_abml.Menu_ABML import show_menu_abml   ModuleNotFoundError: No module named 'menu_abml'

I'll explain to you I have a folder (package) called Python where in that folder is the file Main.py (module), in turn inside Python there is another folder called Menu where the Menu.p module is located and in turn in the Menu folder there is another folder called menu_abml and there there are many files that are actually sub-menus.

Summary: Python (Main.py) > Menu (Menu.py) > menu_abml (Menu_ABML.py, Menu_Patients, Menu_Medical, Menu_Rooms, Menu_modification_patient, etc ...)

So far I managed to connect the functions of the module Menu_ABML.py to the module Menu.py successfully using the from menu_abml.Menu_ABML import (nombre_de_la_función) until there all very nice I connect two modules that are in 1 difference folder. Question, the problem comes when I want to connect the Main.py module that is in the first folder that is Python with the module Menu.py (there is also a difference folder) but I throw away that error that I showed at the beginning.

I'm a beginner in this but I'm sure it's an import problem until I've installed what are the distributable packages with the import setup

to be more flexible when it comes to finding modules.

  

Here I leave my imports with package name and module:

Main.py (Main module of the program) located in the folder C: \ Users \ gero \ Desktop \ Python

from Menu.Menu import *

Inicio()

Menu.py (Main Menu Module) located in the C: \ Users \ gero \ Desktop \ Python \ Menu

from menu_abml.Menu_ABML import show_menu_abml

Menu_ABML.py (Sub-menu ABML) located in the C: \ Users \ gero \ Desktop \ Python \ Menu \ menu_abml

from menu_abml.Menu_Habitaciones import show_menu_Habitaciones
from menu_abml.Menu_Medicos import show_menu_medico
from menu_abml.Menu_Pacientes import show_menu_paciente

There already ends our tour the last import are in the same folder for which no longer have problems, in fact the only one that presents a problem is when I try to run it from the Main.py, because if I execute the Start function ( ) from the Menu.py works perfectly.

    
asked by Gerónimo Membiela 29.12.2018 в 12:18
source

0 answers