-1

This is my directory structure

docker
├── etc
│   └── runit
│       └── artifacts
│           └── refresh-access
└── sbin
    └── cardlib
        ├── auth
        │   └── request_signer.py
        └── sentinel_client.py

I am trying to invoke sentinel_client.py in the refresh-access bash script as below

call_report_health() {
    python3 /sbin/cardlib/sentinel_client.py report_health "$1" "$2"
}

But I am seeing the following error

2023-07-18_13:27:29.20969   File "/sbin/cardlib/sentinel_client.py", line 3, in <module>
2023-07-18_13:27:29.20970     from .auth import request_signer
2023-07-18_13:27:29.20970 ImportError: attempted relative import with no known parent package

How to resolve this issue?

I tried to use absolute path which did not work . I tried to invoke sentinel_client.py as a module which resulted in the below error

2023-07-19_00:21:00.15938 /venv38/bin/python3: Error while finding module specification for 'sbin.cardlib.sentinel_client' (ModuleNotFoundError: No module named 'sbin')
wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • I've never experienced this problem myself, but I think this is the same as this question: [Relative imports in Python 3](/q/16981921/4518341) – wjandrea Jul 19 '23 at 00:53
  • BTW, welcome to Stack Overflow! Check out the [tour] and [ask] for tips like starting with your own research, making a [mre], and how to write a good title. – wjandrea Jul 19 '23 at 00:54
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 19 '23 at 03:58

1 Answers1

0

Remove the . from the import statement

from auth import request_signer

and should work.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134