First of all, thank you in advance for taking the time to contribute with your answers. Even though the message is still warning Import "custom_modules" could not be resolved
, this is how I did it.
I added the following configuration to the __init__.py
script.
# Import the os modules to get access to the os system functions.
import os
# Package level setup
# Package name
__name__="custom_packages"
# Define the import all.
__all__=["custom_modules"]
# Optional define the version of the code.
version="0.0.1"
# Module level configuration
# Importing the module to be configured
from . import custom_modules as cm
# Package setup
cm.__package__="custom_packages"
# Setting up the name of the module
cm.__name__="custom_modules"
# Setting up the path of the module,
cm.__package__.__path__=os.getcwd()
# The os.getcwd() retrieves the current working directory
# allowing us to se the real path instead of the relative one.
# NOTE: this is a very basic setup, that works fine for this sample.
# For a more complete implementation review the python3 docs https://docs.python.org/3/library/
My tree directory is pretty similar to the suggested by you.
./custom_packages/
├── custom_modules.py
├── __init__.py
You can have more detials here.