| 1 |
|
| 2 |
|
| 3 |
import sys |
| 4 |
import importlib |
| 5 |
|
| 6 |
if len(sys.argv) < 2: |
| 7 |
print(f'Usage: {sys.argv[0]} module-name [message]') |
| 8 |
sys.exit(1) |
| 9 |
else: |
| 10 |
module = sys.argv[1] |
| 11 |
|
| 12 |
try: |
| 13 |
importlib.import_module(module) |
| 14 |
except ImportError: |
| 15 |
print() |
| 16 |
print(f'Importing module "{module}" failed.') |
| 17 |
print('The following paths were searched:') |
| 18 |
for x in sys.path: |
| 19 |
print(' ', x) |
| 20 |
print() |
| 21 |
if len(sys.argv) > 2: |
| 22 |
print(sys.argv[2]) |
| 23 |
else: |
| 24 |
print(f'You might need to install module "{module}".') |
| 25 |
print() |
| 26 |
sys.exit(1) |