There was a problem when starting a microservice written in the Nameko framework. When starting the microservice via the command
nameko run name_file_with_class_microservice
The following exception is thrown:
Traceback (most recent call last):
File "/home/user/.pyenv/versions/project/bin/nameko", line 33, in <module>
sys.exit(load_entry_point('nameko==2.12.0', 'console_scripts', 'nameko')())
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/main.py", line 112, in main
args.main(args)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/commands.py", line 110, in main
main(args)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/run.py", line 181, in main
import_service(path)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/run.py", line 46, in import_service
__import__(module_name)
File "./main.py", line 18, in <module>
from commands.object import ObjectUpdateCommand, ObjectExportCommand
File "./commands/object/__init__.py", line 1, in <module>
from .object_export import ObjectExportCommand
File "./commands/object/object_export.py", line 6, in <module>
from ...exception import ProxyException
ImportError: attempted relative import beyond top-level package
I understand this has to do with the "sys.path" variable and where the launch is coming from. However, I do not understand how to make imports workable, both for the entire project as a whole, and for a separate microservice in it (yes, microservices are combined into one repository, for each of which its own docker-file is written)
Everything works if you specify an absolute path relative to the starting point of the microservice. However, this is not suitable for the whole project, PyCharm indicates import curves, autocompletion does not work, and so on.