mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(tools): extend error message for failed python module import
Currently idf.py reports just "Please use idf.py only in an ESP-IDF shell environment". Sometimes it may be useful to know for which module the import failed. Also the problem does not have to be related to shell environment only, but the python venv can be corrupted. This adds a little bit more verbose error message. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
parent
70882235b2
commit
9511180b4a
10
tools/idf.py
10
tools/idf.py
@ -38,9 +38,15 @@ try:
|
|||||||
debug_print_idf_version, get_target, merge_action_lists, print_warning)
|
debug_print_idf_version, get_target, merge_action_lists, print_warning)
|
||||||
if os.getenv('IDF_COMPONENT_MANAGER') != '0':
|
if os.getenv('IDF_COMPONENT_MANAGER') != '0':
|
||||||
from idf_component_manager import idf_extensions
|
from idf_component_manager import idf_extensions
|
||||||
except ImportError:
|
except ImportError as e:
|
||||||
# For example, importing click could cause this.
|
# For example, importing click could cause this.
|
||||||
print('Please use idf.py only in an ESP-IDF shell environment.', file=sys.stderr)
|
print((f'Cannot import module "{e.name}". This usually means that "idf.py" was not '
|
||||||
|
f'spawned within an ESP-IDF shell environment or the python virtual '
|
||||||
|
f'environment used by "idf.py" is corrupted.\n'
|
||||||
|
f'Please use idf.py only in an ESP-IDF shell environment. If problem persists, '
|
||||||
|
f'please try to install ESP-IDF tools again as described in the Get Started guide.'),
|
||||||
|
file=sys.stderr)
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Use this Python interpreter for any subprocesses we launch
|
# Use this Python interpreter for any subprocesses we launch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user