mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-04 20:46:45 +00:00
community[minor]: import fix (#20995)
Issue: When the third-party package is not installed, whenever we need to `pip install <package>` the ImportError is raised. But sometimes, the `ValueError` or `ModuleNotFoundError` is raised. It is bad for consistency. Change: replaced the `ValueError` or `ModuleNotFoundError` with `ImportError` when we raise an error with the `pip install <package>` message. Note: Ideally, we replace all `try: import... except... raise ... `with helper functions like `import_aim` or just use the existing [langchain_core.utils.utils.guard_import](https://api.python.langchain.com/en/latest/utils/langchain_core.utils.utils.guard_import.html#langchain_core.utils.utils.guard_import) But it would be much bigger refactoring. @baskaryan Please, advice on this.
This commit is contained in:
@@ -634,7 +634,7 @@ class AmazonTextractPDFLoader(BasePDFLoader):
|
||||
try:
|
||||
import textractcaller as tc # noqa: F401
|
||||
except ImportError:
|
||||
raise ModuleNotFoundError(
|
||||
raise ImportError(
|
||||
"Could not import amazon-textract-caller python package. "
|
||||
"Please install it with `pip install amazon-textract-caller`."
|
||||
)
|
||||
@@ -662,7 +662,7 @@ class AmazonTextractPDFLoader(BasePDFLoader):
|
||||
client = session.client("textract", **client_params)
|
||||
|
||||
except ImportError:
|
||||
raise ModuleNotFoundError(
|
||||
raise ImportError(
|
||||
"Could not import boto3 python package. "
|
||||
"Please install it with `pip install boto3`."
|
||||
)
|
||||
@@ -710,7 +710,7 @@ class AmazonTextractPDFLoader(BasePDFLoader):
|
||||
from PIL import Image, ImageSequence
|
||||
|
||||
except ImportError:
|
||||
raise ModuleNotFoundError(
|
||||
raise ImportError(
|
||||
"Could not import pypdf or Pilloe python package. "
|
||||
"Please install it with `pip install pypdf Pillow`."
|
||||
)
|
||||
|
Reference in New Issue
Block a user