From ce6338f8a6694396990f77c19bbc3d003b12f9b9 Mon Sep 17 00:00:00 2001 From: Nico Zevallos Date: Thu, 17 Jan 2019 11:58:26 -0500 Subject: [PATCH] Changed behaviour when encountering import errors for easier debugging. (#1031) --- examples/tutorial_api_python/1_body_from_image.py | 5 +++-- examples/tutorial_api_python/2_whole_body_from_image.py | 5 +++-- examples/tutorial_api_python/3_heatmaps_from_image.py | 5 +++-- examples/tutorial_api_python/openpose_python.py | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/tutorial_api_python/1_body_from_image.py b/examples/tutorial_api_python/1_body_from_image.py index c0b9ae2a..f89225f4 100644 --- a/examples/tutorial_api_python/1_body_from_image.py +++ b/examples/tutorial_api_python/1_body_from_image.py @@ -21,8 +21,9 @@ try: # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. # sys.path.append('/usr/local/python') from openpose import pyopenpose as op -except: - raise Exception('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e # Flags parser = argparse.ArgumentParser() diff --git a/examples/tutorial_api_python/2_whole_body_from_image.py b/examples/tutorial_api_python/2_whole_body_from_image.py index b43a56ed..fbf7f8a6 100644 --- a/examples/tutorial_api_python/2_whole_body_from_image.py +++ b/examples/tutorial_api_python/2_whole_body_from_image.py @@ -21,8 +21,9 @@ try: # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. # sys.path.append('/usr/local/python') from openpose import pyopenpose as op -except: - raise Exception('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e # Flags parser = argparse.ArgumentParser() diff --git a/examples/tutorial_api_python/3_heatmaps_from_image.py b/examples/tutorial_api_python/3_heatmaps_from_image.py index 79d9b381..0d16812d 100644 --- a/examples/tutorial_api_python/3_heatmaps_from_image.py +++ b/examples/tutorial_api_python/3_heatmaps_from_image.py @@ -22,8 +22,9 @@ try: # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. # sys.path.append('/usr/local/python') from openpose import pyopenpose as op -except: - raise Exception('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e # Flags parser = argparse.ArgumentParser() diff --git a/examples/tutorial_api_python/openpose_python.py b/examples/tutorial_api_python/openpose_python.py index 70a66be2..9d2f0a3b 100644 --- a/examples/tutorial_api_python/openpose_python.py +++ b/examples/tutorial_api_python/openpose_python.py @@ -21,8 +21,9 @@ try: # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it. # sys.path.append('/usr/local/python') from openpose import pyopenpose as op -except: - raise Exception('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') +except ImportError as e: + print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?') + raise e # Flags parser = argparse.ArgumentParser() -- GitLab